Skip to content

Request: Make GrpcTimeout pub #2519

@itsjunetime

Description

@itsjunetime

Feature Request

It would be very useful to me if the GrpcTimeout struct and helper function within 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 and Connection, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions