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

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

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

Implementors