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

Re-use Request instance? #694

Open
ERnsTL opened this issue Jun 27, 2021 · 3 comments
Open

Re-use Request instance? #694

ERnsTL opened this issue Jun 27, 2021 · 3 comments
Labels
A-tonic S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work.

Comments

@ERnsTL
Copy link

ERnsTL commented Jun 27, 2021

Feature Request

Crates

tonic

Motivation

tonic seems slow in use-cases where many similar requests need to be sent.

Proposal

Re-use of the tonic::Request instance, just setting the payload new -- or even just overwriting some fields of the payload.

Very simple example:

        let request = tonic::Request::new(WeatherRequest{
                location: "Vienna/Austria".into()
        });

Current situation: "trait Copy not implemented for struct Request" -- "value moved in previous iteration".

Alternatives

Not sure.

@Jason5Lee
Copy link

I think it's related to tokio-rs/prost/issues/429, currently Rust protobuf generator doesn't allow you to choose the pointer, in which case you're not allowed to use Arc for reusing value. I hope it can be implemented soon.

@davidpdrsn davidpdrsn added A-tonic S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work. labels Jul 8, 2021
@LucioFranco
Copy link
Member

http::Request is not clonable due to the Extensions type it uses. You can though construct your proto to use bytes and then use the bytes feature in prost to have the bytes field be Bytes. This then would allow you to cheaply clone the bytes and avoid heavy clones.

@LucioFranco
Copy link
Member

Related issue hyperium/http#395

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tonic S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work.
Projects
None yet
Development

No branches or pull requests

4 participants