pub trait Runner<'a, Shared, Event, Return>{
// Required methods
fn setup<'async_trait>(
region: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Shared>> + Send + 'async_trait>>
where 'a: 'async_trait;
fn run<'async_trait>(
shared: &'a Shared,
event: LambdaEvent<'a, Event>,
) -> Pin<Box<dyn Future<Output = Result<Return>> + Send + 'async_trait>>
where 'a: 'async_trait;
}
Expand description
Defines a type which is executed every time a lambda is invoced.
Types:
Shared
: Type which is shared between lambda invocations. Note that lambda will create multiple environments for simulations invokations and environments are only kept alive for a certain time. It is thus not guaranteed that data can be reused, but with this types its possible.Event
: The expected Event which is being send to the lambda by AWS.Return
: Type which is the result of the lamba invocation being returned to AWS
Required Methods§
Sourcefn setup<'async_trait>(
region: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Shared>> + Send + 'async_trait>>where
'a: 'async_trait,
fn setup<'async_trait>(
region: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Shared>> + Send + 'async_trait>>where
'a: 'async_trait,
Invoked only once before lambda runtime start. Does not get called on each lambda invocation. Can be used to setup logging and other global services, but should be short as it delays lambda startup
Sourcefn run<'async_trait>(
shared: &'a Shared,
event: LambdaEvent<'a, Event>,
) -> Pin<Box<dyn Future<Output = Result<Return>> + Send + 'async_trait>>where
'a: 'async_trait,
fn run<'async_trait>(
shared: &'a Shared,
event: LambdaEvent<'a, Event>,
) -> Pin<Box<dyn Future<Output = Result<Return>> + Send + 'async_trait>>where
'a: 'async_trait,
Invoked for every lambda invocation. Data in shared
is persisted between
invocations as long as they are running in the same execution environment
More Info: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.