Request: Make `GrpcTimeout` pub
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Feature Request
It would be very useful to me if the [GrpcTimeout struct and helper function within grpc_timeout.rs](https://github.com/hyperium/tonic/blob/e6318b70a98735321927047f7d2b69c5d1712353/tonic/src/transport/service/grpc_timeout.rs) were made public. I would like to use them, but it seems that they're currently not exposed for public consumption and instead only usable through structs like [`MakeSvc`](https://github.com/hyperium/tonic/blob/e6318b70a98735321927047f7d2b69c5d1712353/tonic/src/transport/server/mod.rs#L1239) and [`Connection`](https://github.com/hyperium/tonic/blob/e6318b70a98735321927047f7d2b69c5d1712353/tonic/src/transport/channel/service/connection.rs#L65), neither of which we use.
### Crates
Just `tonic`
### Motivation
If `GrpcTimeout` (and, ideally, the `try_parse_grpc_timeout` function in the same file which helps parse a `HeaderMap` into a value for the timeout) were made public, that would be very useful to me. I'd love to be able to have this layer in my code, and it would be nice to not have to copy it out of `tonic` or depend on a fork of tonic or something like that.
### Proposal
I think that `GrpcTimeout` can probably be comfortably made `pub` (instead of `pub(crate)`) and exposed for wider consumption.
I also would guess that `try_parse_grpc_timeout` probably wasn't built for public consumption in mind? So maybe that would benefit from some alterations, e.g. a more comprehensive error case or maybe moving the function to a custom `GrpcTimeoutDuration` struct's `FromStr` impl (or something like that). Not quite sure about this, though - I would appreciate input from the tonic team on what is most idiomatic for tonic to do here.
### Alternatives
As I mentioned earlier, I can copy over the contents of the file into my own project, and just use it like that, or depend on a fork of `tonic` which exposes these functions I need. Both of these solutions are doable, but just not ideal. They'll add extra friction and annoyance whenever tonic needs to update anything, and copying the file over would just unnecessarily add more code that already exists elsewhere.
I also expect that making them public won't only benefit me - I expect that there are other people out there who would also like to use this functionality but don't have their servers set up in a way that currently supports the existing `GrpcTimeout` piping. This means that any alternative of a fork or file copy would have to be done by everyone trying to use `GrpcTimeout` in their own way, and that's just not ideal.
Contributor guide
Assessment
This issue has not been assessed yet.