lamedh-dev / aws-lambda-rust-runtime

Apache License 2.0
84 stars 13 forks source link

Help implementing a Rocket handler #19

Closed dbanty closed 3 years ago

dbanty commented 3 years ago

I'm attempting to port rocket_lamb to the latest Rocket which supports Tokio 1.x. To do so, I switched from the last release of the AWS lambda runtime (still on Tokio 0.1) to this crate.

In switching to the Handler trait from this repo, I've hit a roadblock where the Future I return has to be 'static but the reference to self isn't necessarily. This is an issue because my Handler contains the Rocket instance which does the actual processing of the request. So my Future is going to be based somehow on the lifetime of the reference to self.

I don't want to have to construct a new Rocket for every request but I'm not sure what to do at this point. Any help to point me in the right direction would be very much appreciated.

My repo is https://github.com/dbanty/rocket-lamb if you want to clone and cargo check to see what I'm talking about.

calavera commented 3 years ago

Hey, thanks for opening this issue!

I'm not really familiar with that project, but your comment makes me wonder if this problem can be solved in the same way that @jessbowers-DSS implemented the stateful http example:

https://github.com/lamedh-dev/aws-lambda-rust-runtime/blob/main/lambda-http/examples/stateful-http.rs

dbanty commented 3 years ago

Thanks for the quick response! Using Arcs all over the place certainly seemed to get me further. I haven't yet finished digging through the cascade of errors but I'm making progress again so I think this particular blocker is solved!