Hello all,
Recently I've finally found some time to polish and generalize a set of classes providing Guice scopes for gRPC and websockets, that I was copy-pasting-tweaking for every java project for last few years: maybe someone else will find it useful :)
Provides `rpcScope` and `listenerCallScope`. Oversimplifying, in case of a streaming client, `listenerCallScope` spans over processing of a single message from client's stream, while `rpcScope` spans over a whole given RPC. Oversimplifying again, in case of a unary client, these 2 scopes have roughly the same span.
Provides
`requestScope` spans over HTTP servlet requests and websocket events, such as connection open/closed or message received (ie, over each of endpoints' annotated methods or overriding those of Endpoint)
`websocketConnectionScope` spans over a whole endpoint connection (javax.websocket.Session)
`httpSessionScope` available both to servlets and websocket endpoints
answering in advance why websocket scopes are not built on top of the official servlet scopes:
- this implementation is thread-safe: a single request can be handled by multiple threads (as long as accessed scoped objects are thread-safe)
- guice-context-scopes lib was first developed for gRPC scopes. After that, it felt more natural to use it also for websocket scopes, rather than pretend that everything is an HttpServletRequest. I may be biased here however ;-)
Feedback is welcome :)
Cheers!