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

Add custom behavior to Tonic Connections #2102

Open
giladwolff opened this issue Dec 16, 2024 · 0 comments
Open

Add custom behavior to Tonic Connections #2102

giladwolff opened this issue Dec 16, 2024 · 0 comments

Comments

@giladwolff
Copy link

Feature Request

Expose a way to add a custom behavior to a connection.

Crates

tonic

Motivation

Tonic instantiates a service stack when creating a connection (see here). Some of the layers in the service stack are dynamic and generated as a result of configuration contained in the Endpoint object. There is no way to add an arbitrary layer to this stack to modify the behavior of a connection.

We use a balance_channel to manage a list of endpoints for our grpc clients. We
have two use-cases that will benefit from the ability to add custom behavior:
(a) adding circuit-breaker per endpoint and (b) adding metrics per connection. On top of that, adding this can help with other use cases like #1970.

Proposal

I can think of two ways to add this behavior. One is to add a custom layer as part of
the connection service instantiation here. Another is to add a custom layer when instantiating a service as part of
MakeSendRequestService.

I will be happy to work on a solution - I played with both of the above but
before investing more time would like to agree upon a solution.

Alternatives

One way to overcome this is to instantiate multiple grpc clients each one
using a single endpoint channel. I will probably go down that route if
there is no other way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant