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 :)

https://github.com/morgwai/grpc-scopes
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.

https://github.com/morgwai/servlet-scopes
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

both libs are built on top of 
https://github.com/morgwai/guice-context-scopes which automates 
transferring scopes when dispatching work to new threads (useful for async 
processing).

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!

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/58994da7-e609-4cf1-8775-f35465dbb6b1n%40googlegroups.com.

Reply via email to