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