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

Restore methods to transform into tower service #2127

Open
dnaka91 opened this issue Jan 9, 2025 · 0 comments
Open

Restore methods to transform into tower service #2127

dnaka91 opened this issue Jan 9, 2025 · 0 comments

Comments

@dnaka91
Copy link

dnaka91 commented Jan 9, 2025

Feature Request

Restore the methods that allow to turn tonic servers into tower services and expose the tower crates at least to some degree again, to allow for interoperability with other tower-based crates.

Crates

Only the tonic crate itself as far as I'm aware, but it might extend to the extra crates to some degree.

Motivation

At work we use the tonic crate in several projects, and it's a crucial crate for us. As there have been many changes since the last 0.12.3 release I was trying out the very latest version from Git and saw that the tower conversion methods are gone (namely into_service).

I saw in the commit history that these have been considered deprecated and later removed, and further changes have been done to internalize the tower crate, which is understandable from the point of hiding some details behind the public API to gain more freedom in internal changess and reduce breaking changes.

However, this is a big deal breaker for us, as it basically strips tonic of the neat feature of inter-operating with other crates that build on top of tower, which is a key feature of tower.

We use a mix of hyper, axum and tonic and often we have to glue them together or do some pre/post-processing before things arrive at the tonic level or after leaving it.

For example, we do some processing of requests in hyper on the HTTP-level, and only later pass it on to tonic to handle the actual request on the gRPC level. So in our setup we often call tonic instead of tonic calling us, meaning that we use it as a tower service where we call it per TCP stream or per request and do all sorts of custom stuff with TLS and other details around it.

So without any way in the upcoming version of turning a tonic server back into a tower service, we have no obvious path to upgrade.

Proposal

Re-instate the previous APIs (still present in 0.12.3) or introduce new ones, which allow to transform from a tonic server into a tower service/make-service.

Alternatives

I have tried to get it to work through some of the components in the service module instead of the transport::server module, in the hopes I can somehow turn it into an axum router and get it to work.

However, that only worked until I tried to apply the grpc-web layer, which requires different types on the request and response and I found no good way of gluing those together.

Also, the new APIs feel very defensive in general and not really open to combining tonic with anything else but itself (in contrast to axum for example, which feels very extensible). For example, the tonic interceptors are too limited and we really need the tower middlewares like map_result or map_request here, to just name a few.

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