File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed
examples/extension-internal-flush Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,4 @@ aws_lambda_events = { path = "../../lambda-events" }
99lambda-extension = { path = " ../../lambda-extension" }
1010lambda_runtime = { path = " ../../lambda-runtime" }
1111serde = " 1.0.136"
12- tokio = { version = " 1" , features = [" macros" , " sync" ] }
12+ tokio = { version = " 1.46 " , features = [" macros" , " sync" ] }
Original file line number Diff line number Diff line change @@ -101,9 +101,11 @@ async fn main() -> Result<(), Error> {
101101
102102 let handler = Arc :: new ( EventHandler :: new ( request_done_sender) ) ;
103103
104- // TODO: add biased! to always poll the handler future first, once supported:
105- // https://github.com/tokio-rs/tokio/issues/7304
106104 tokio:: try_join!(
105+ // always poll the handler function first before the flush extension,
106+ // this results in a smaller future due to not needing to track which was polled first
107+ // each time, and also a tiny latency savings
108+ biased;
107109 lambda_runtime:: run( service_fn( |event| {
108110 let handler = handler. clone( ) ;
109111 async move { handler. invoke( event) . await }
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ pin-project = "1"
5252serde = { version = " 1" , features = [" derive" , " rc" ] }
5353serde_json = " ^1"
5454serde_path_to_error = " 0.1.11"
55- tokio = { version = " 1.0 " , features = [
55+ tokio = { version = " 1.46 " , features = [
5656 " macros" ,
5757 " io-util" ,
5858 " sync" ,
Original file line number Diff line number Diff line change @@ -223,9 +223,11 @@ where
223223 }
224224 } ;
225225
226- // TODO: add biased! to always poll the signal handling future first, once supported:
227- // https://github.com/tokio-rs/tokio/issues/7304
228- let _: ( _ , ( ) ) = tokio:: join!( graceful_shutdown_future, async {
226+ let _: ( _ , ( ) ) = tokio:: join!(
227+ // we always poll the graceful shutdown future first,
228+ // which results in a smaller future due to lack of bookkeeping of which was last polled
229+ biased;
230+ graceful_shutdown_future, async {
229231 // we suppress extension errors because we don't actually mind if it crashes,
230232 // all we need to do is kick off the run so that lambda exits the init phase
231233 let _ = extension. run( ) . await ;
You can’t perform that action at this time.
0 commit comments