lambda_extension/
lib.rs

1#![deny(clippy::all, clippy::cargo)]
2#![allow(clippy::multiple_crate_versions, clippy::type_complexity)]
3#![warn(missing_docs, nonstandard_style, rust_2018_idioms)]
4
5//! This module includes utilities to create Lambda Runtime Extensions.
6//!
7//! Create a type that conforms to the [`Extension`] trait. This type can then be passed
8//! to the the `lambda_extension::run` function, which launches and runs the Lambda runtime extension.
9use std::{fmt, future::Future};
10pub use tower::{self, make::Shared as SharedService, service_fn, Service};
11
12mod error;
13pub use error::*;
14mod extension;
15pub use extension::*;
16mod events;
17pub use events::*;
18mod logs;
19pub use logs::*;
20mod telemetry;
21pub use telemetry::*;
22
23/// Include several request builders to interact with the Extension API.
24pub mod requests;
25
26/// Utilities to initialize and use `tracing` and `tracing-subscriber` in Lambda Functions.
27#[cfg(feature = "tracing")]
28pub use lambda_runtime_api_client::tracing;
29
30/// Execute the given events processor
31pub async fn run<E>(events_processor: E) -> Result<(), Error>
32where
33    E: Service<LambdaEvent>,
34    E::Future: Future<Output = Result<(), E::Error>>,
35    E::Error: Into<Box<dyn std::error::Error + Send + Sync>> + fmt::Display + fmt::Debug,
36{
37    let ext = Extension::new().with_events_processor(events_processor);
38    ext.run().await
39}