Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "context" within the server. #177

Closed
LucioFranco opened this issue Dec 12, 2019 · 3 comments
Closed

Support "context" within the server. #177

LucioFranco opened this issue Dec 12, 2019 · 3 comments
Assignees
Labels
A-tonic C-enhancement Category: New feature or request

Comments

@LucioFranco
Copy link
Member

I would like to add "context" (I am using quotes because I think this is a bad word) support within tonic's transport server. This should be done via a similar method that http::Request has an extenions with an AnyMap behind it. This way we can let the interceptor/or any other type of transport populate it, then let users get the "context" from request handlers. Then the transport module can expose newtypes that allow users to guarantee they are fetching the correct item from the anymap.

Once, we have this in place we can populate it with the peer addr and the tls config.

(sorry for the messy write up I am in a hurry :) )

@LucioFranco LucioFranco added C-enhancement Category: New feature or request A-tonic labels Dec 12, 2019
@LucioFranco LucioFranco self-assigned this Dec 12, 2019
@Farenjihn
Copy link

Farenjihn commented Dec 12, 2019

Thanks for opening up an issue !

IIUC, this would allow implementors of a gRPC service (through the generated trait) to access this "context", for lack of a better term. So effectively, tonic's Request type would implement a mechanism similar to http's request extensions.

Given that interceptors currently receive http's Request type as argument, how would it work to read data from said "context" within them ? Would interceptors only serve as a way to populate the "context" and is it going to be necessary to move logging / access control / etc... to each function in the generated trait ?

Apart from that, can I help you with getting this done or is everything already in the works on your end ?

@LucioFranco
Copy link
Member Author

@Farenjihn Yeah, that is the idea, I am not sure yet how to mix and match http with its request extensions. I'd also like to find a better way to let users inject logging. My goal is to get 0.1 out by next week and I want to include these features.

@LucioFranco
Copy link
Member Author

This was done in #186 and lays the groundwork for further things to be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tonic C-enhancement Category: New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants