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

Inconsistent Server Builder api - timeout func returns &mut Self instead of Self #900

Closed
jdahlq opened this issue Jan 30, 2022 · 1 comment
Milestone

Comments

@jdahlq
Copy link
Contributor

jdahlq commented Jan 30, 2022

Feature Request

Crates

tonic

Motivation

Similar functions in the Builder return Self rather than &mut Self enabling move semantics, but timeout doesn't, leading to quirky behavior.

// This compiles because `add_service` takes a `&mut Self` and clones it.
let router = Server::builder()
  .accept_http1(true)
  .timeout(Duration::from_secs(10))
  .add_service(my_svc);

// This does NOT compile because `accept_http1` takes a `Self` but cannot move or copy it.
let router = Server::builder()
  .timeout(Duration::from_secs(10))
  .accept_http1(true)
  .add_service(my_svc);

Issue #115 changed most of these functions to return Self, but timeout was (re-)introduced in PR #199 and (presumably unintentionally) uses the old behavior of returning &mut Self.

Proposal

Make timeout consistent with other funcs like accept_http1, concurrency_limit_per_connection, etc.

jdahlq added a commit to jdahlq/tonic that referenced this issue Jan 30, 2022
…ilder

transport/server/mod.rs exposes a Builder for the Server, and most of the
Builder functions return Self (a change made for issue hyperium#115), but timeout
returns mut& Self. This change makes timeout consistent with the rest of
the Builder api by returning Self.

Fixes: hyperium#900
Refs: hyperium#115
@LucioFranco
Copy link
Member

Nice catch! Yeah, we should get this fixed :)

@LucioFranco LucioFranco added this to the 0.7 milestone Feb 14, 2022
jdahlq added a commit to jdahlq/tonic that referenced this issue Feb 18, 2022
…ilder

transport/server/mod.rs exposes a Builder for the Server, and most of the
Builder functions return Self (a change made for issue hyperium#115), but timeout
returns mut& Self. This change makes timeout consistent with the rest of
the Builder api by returning Self.

Fixes: hyperium#900
Refs: hyperium#115
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

2 participants