-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a module to group all streaming functionality.
This makes the streaming functionallity more concise. It aliases other functionality to keep backwards compatibility. Signed-off-by: David Calavera <[email protected]>
- Loading branch information
Showing
7 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
pub use lambda_runtime_api_client::body::{sender::Sender, Body}; | ||
|
||
pub use crate::types::StreamResponse as Response; | ||
|
||
/// Create a new `Body` stream with associated Sender half. | ||
/// | ||
/// Examples | ||
/// | ||
/// ``` | ||
/// use lambda_runtime::{ | ||
/// streaming::{channel, Body, Response}, | ||
/// Error, LambdaEvent, | ||
/// }; | ||
/// use std::{thread, time::Duration}; | ||
/// | ||
/// async fn func(_event: LambdaEvent<serde_json::Value>) -> Result<Response<Body>, Error> { | ||
/// let messages = vec!["Hello", "world", "from", "Lambda!"]; | ||
/// | ||
/// let (mut tx, rx) = channel(); | ||
/// | ||
/// tokio::spawn(async move { | ||
/// for message in messages.iter() { | ||
/// tx.send_data((message.to_string() + "\n").into()).await.unwrap(); | ||
/// thread::sleep(Duration::from_millis(500)); | ||
/// } | ||
/// }); | ||
/// | ||
/// Ok(Response::from(rx)) | ||
/// } | ||
/// ``` | ||
#[allow(unused)] | ||
#[inline] | ||
pub fn channel() -> (Sender, Body) { | ||
Body::channel() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters