Trait Runner

Source
pub trait Runner<'a, Shared, Event, Return>
where Shared: Send + Sync + 'a, Event: for<'de> Deserialize<'de> + Debug, Return: Serialize,
{ // 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§

Source

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

Source

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.

Implementors§

Source§

impl<'a, Type, Shared, Sec> Runner<'a, Shared, Event<Sec>, ()> for Type
where Shared: Send + Sync + 'a, Sec: 'static + Send + Sync + Clone + DeserializeOwned + Serialize, Type: 'static + RotateRunner<'a, Shared, Sec>,

Available on crate features rotate_rusoto or rotate_aws_sdk only.