Skip to content

Commit f404617

Browse files
authored
Replace genawaiter with async-stream (#240)
1 parent e528ef6 commit f404617

File tree

3 files changed

+30
-82
lines changed

3 files changed

+30
-82
lines changed

Cargo.lock

Lines changed: 22 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ tower-service = "0.3"
2020
bytes = "0.5"
2121
http = "0.2"
2222
lambda-attributes = { path = "../lambda-attributes", version = "0.1.0", optional = true}
23-
genawaiter = { version = "0.99", features = ["futures03"] }
23+
async-stream = "0.2"
2424
futures = "0.3"
2525
tracing = "0.1.13"
2626
tracing-futures = "0.2.3"

lambda/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
pub use crate::types::Context;
3737
use client::Client;
3838
use futures::stream::{Stream, StreamExt};
39-
use genawaiter::{sync::gen, yield_};
4039
pub use lambda_attributes::lambda;
4140
use serde::{Deserialize, Serialize};
4241
use std::{
@@ -179,17 +178,18 @@ where
179178
}
180179

181180
fn incoming(client: &Client) -> impl Stream<Item = Result<http::Response<hyper::Body>, Error>> + '_ {
182-
gen!({
181+
async_stream::stream! {
183182
loop {
184183
let req = NextEventRequest.into_req().expect("Unable to construct request");
185-
yield_!(client.call(req).await)
184+
let res = client.call(req).await;
185+
yield res;
186186
}
187-
})
187+
}
188188
}
189189

190190
async fn run_inner<A, B, F>(
191191
client: &Client,
192-
incoming: impl Stream<Item = Result<http::Response<hyper::Body>, Error>> + Unpin,
192+
incoming: impl Stream<Item = Result<http::Response<hyper::Body>, Error>>,
193193
handler: &mut F,
194194
) -> Result<(), Error>
195195
where
@@ -198,7 +198,8 @@ where
198198
A: for<'de> Deserialize<'de>,
199199
B: Serialize,
200200
{
201-
let mut incoming = incoming;
201+
tokio::pin!(incoming);
202+
202203
while let Some(event) = incoming.next().await {
203204
let event = event?;
204205
let (parts, body) = event.into_parts();

0 commit comments

Comments
 (0)