Skip to content

Commit 64cd7df

Browse files
LucioFrancodavidbarsky
authored andcommitted
Replace genawaiter with async-stream (#240)
1 parent eed16d1 commit 64cd7df

File tree

3 files changed

+30
-82
lines changed

3 files changed

+30
-82
lines changed

Cargo.lock

+22-75
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ 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"

lambda/src/lib.rs

+7-6
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::{
@@ -163,17 +162,18 @@ where
163162
}
164163

165164
fn incoming(client: &Client) -> impl Stream<Item = Result<http::Response<hyper::Body>, Error>> + '_ {
166-
gen!({
165+
async_stream::stream! {
167166
loop {
168167
let req = NextEventRequest.into_req().expect("Unable to construct request");
169-
yield_!(client.call(req).await)
168+
let res = client.call(req).await;
169+
yield res;
170170
}
171-
})
171+
}
172172
}
173173

174174
async fn run_inner<A, B, F>(
175175
client: &Client,
176-
incoming: impl Stream<Item = Result<http::Response<hyper::Body>, Error>> + Unpin,
176+
incoming: impl Stream<Item = Result<http::Response<hyper::Body>, Error>>,
177177
handler: &mut F,
178178
) -> Result<(), Error>
179179
where
@@ -182,7 +182,8 @@ where
182182
A: for<'de> Deserialize<'de>,
183183
B: Serialize,
184184
{
185-
let mut incoming = incoming;
185+
tokio::pin!(incoming);
186+
186187
while let Some(event) = incoming.next().await {
187188
let event = event?;
188189
let (parts, body) = event.into_parts();

0 commit comments

Comments
 (0)