| 181 | /// This function panics if called outside of a Tokio runtime. |
| 182 | #[cfg_attr(docsrs, doc(cfg(feature = "concurrency-tokio")))] |
| 183 | pub async fn run_concurrent(self) -> Result<(), BoxError> { |
| 184 | if tokio::runtime::Handle::try_current().is_err() { |
| 185 | panic!("`run_concurrent` must be called from within a Tokio runtime"); |
| 186 | } |
| 187 | |
| 188 | if self.concurrency_limit > 1 { |
| 189 | trace!("Concurrent mode: _X_AMZN_TRACE_ID is not set; use context.xray_trace_id"); |
| 190 | Self::run_concurrent_inner(self.service, self.config, self.client, self.concurrency_limit).await |
| 191 | } else { |
| 192 | debug!( |
| 193 | "Concurrent polling disabled (AWS_LAMBDA_MAX_CONCURRENCY unset or <= 1); falling back to sequential polling" |
| 194 | ); |
| 195 | let incoming = incoming(&self.client); |
| 196 | Self::run_with_incoming(self.service, self.config, incoming).await |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | /// Concurrent processing using N independent long-poll loops (for Lambda managed-concurrency). |
| 201 | async fn run_concurrent_inner( |