-
Notifications
You must be signed in to change notification settings - Fork 380
Lambda Extensions #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Lambda Extensions #376
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
046d380
Create new Runtime Client crate
calavera 19e1ceb
Add Lambda Extension crate
calavera 9d46537
Rename client crate to avoid confusion.
calavera a7161be
Modify user API.
calavera af95f36
Cleanup user API.
calavera c5b423a
Add documentation and cleanup code.
calavera 23b3631
Make custom trait example more useful.
calavera 36cdbd8
Fix formatting.
calavera 6110926
Remove unused dependencies.
calavera f607efa
Add README files for the new crates.
calavera bbde541
Update readme files.
calavera 981b7ce
Fix extension name
calavera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Cleanup user API.
- Remove extension ID from call signature. - Make extension mutable. - Add example showing how to implement an extension with a struct. Signed-off-by: David Calavera <[email protected]>
- Loading branch information
commit af95f363070646c914d7a1c38620c2e591062ca4
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
| use lambda_extension::{run, Error, NextEvent, Extension}; | ||
| use log::LevelFilter; | ||
| use simple_logger::SimpleLogger; | ||
| use std::future::{Future, ready}; | ||
| use std::pin::Pin; | ||
|
|
||
| struct MyExtension {} | ||
|
|
||
| impl Extension for MyExtension | ||
| { | ||
| type Fut = Pin<Box<dyn Future<Output = Result<(), Error>>>>; | ||
| fn call(&mut self, event: NextEvent) -> Self::Fut { | ||
| match event { | ||
| NextEvent::Shutdown(_e) => { | ||
| // do something with the shutdown event | ||
| } | ||
| _ => { | ||
| // ignore any other event | ||
| // because we've registered the extension | ||
| // only to receive SHUTDOWN events | ||
| } | ||
| } | ||
| Box::pin(ready(Ok(()))) | ||
| } | ||
| } | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Error> { | ||
| // required to enable CloudWatch error logging by the runtime | ||
| // can be replaced with any other method of initializing `log` | ||
| SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap(); | ||
|
|
||
| run(MyExtension {}).await | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.