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" }
9
9
lambda-extension = { path = " ../../lambda-extension" }
10
10
lambda_runtime = { path = " ../../lambda-runtime" }
11
11
serde = " 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> {
101
101
102
102
let handler = Arc :: new ( EventHandler :: new ( request_done_sender) ) ;
103
103
104
- // TODO: add biased! to always poll the handler future first, once supported:
105
- // https://github.com/tokio-rs/tokio/issues/7304
106
104
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;
107
109
lambda_runtime:: run( service_fn( |event| {
108
110
let handler = handler. clone( ) ;
109
111
async move { handler. invoke( event) . await }
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ pin-project = "1"
52
52
serde = { version = " 1" , features = [" derive" , " rc" ] }
53
53
serde_json = " ^1"
54
54
serde_path_to_error = " 0.1.11"
55
- tokio = { version = " 1.0 " , features = [
55
+ tokio = { version = " 1.46 " , features = [
56
56
" macros" ,
57
57
" io-util" ,
58
58
" sync" ,
Original file line number Diff line number Diff line change @@ -223,9 +223,11 @@ where
223
223
}
224
224
} ;
225
225
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 {
229
231
// we suppress extension errors because we don't actually mind if it crashes,
230
232
// all we need to do is kick off the run so that lambda exits the init phase
231
233
let _ = extension. run( ) . await ;
You can’t perform that action at this time.
0 commit comments