Skip to content

Custom context #458

@0xDjole

Description

@0xDjole

I am trying to create custom context that gets reused between invocations.
Here specifically trying to reuse mongodb client.

 // ...initing mongo database

  let custom_context = CustomContext {
        mongo_database: Some(mongo_database),
   };

   lambda_runtime::run(handler_fn(|event: Request, ctx: Context| {
       execute(event, ctx, &custom_context)
   }))

Getting: Closure may outlive the current function, but it borrows custom_context, which is owned by the current function

Can handler_fn be used to support something like this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions