You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The run function accepts any type which implements Handler so I believe you can just have a type with state that lives across invocations of a lambda task that implements Handler
example pseudo code
structCounter{data:usize}implDefaultforCounter{fndefault() -> Self{Counter{data:0}}}implHandler<A,B>forCounter{typeError = YourErrType;typeFut = YourFutType;fncall(&mutself,req:A,ctx:Context) -> Self::Fut{// update your stateself.data += 1;// do the thing that returns Self::Fut}}fnmain(){
lambda_runtime::run(Counter::default()).await?;Ok(())}
Reacted by mx, Sean Pianka, Nicolas Moutschen and Colton Weaver
Activity
softprops commentedon Nov 22, 2021
hander_fn is a factory method for creating an instance of a type which implements a generic Handler trait.
The
runfunction accepts any type which implementsHandlerso I believe you can just have a type with state that lives across invocations of a lambda task that implementsHandlerexample pseudo code