-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-serverArea: server.Area: server.B-breaking-changeBlocked: this is an "API breaking change".Blocked: this is an "API breaking change".C-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.E-easyEffort: easy. A task that would be a great starting point for a new contributor.Effort: easy. A task that would be a great starting point for a new contributor.
Milestone
Description
Now that hyper defines its own Service
trait (#2853), there's a key part we should clarify before hitting 1.0 Final: Should it take &self
or &mut self
? Whichever the decision, the why should be documented (not necessarily in the API docs, but in code comments or in the docs/
folder).
The usual arguments are here:
&self
- It prepares the way for
async fn
, since then the future only borrows&self
, and thus aService
can concurrently handle multiple outstanding requests at once. - It's clearer that
Service
s can likely be cloned.
- It prepares the way for
&mut self
- If a
Service
has state (usually per-connection), it's cheaper to mutate it on each connection. Not being&mut
would require internal synchronization.
- If a
I'm happy to open it up to discussion here. I'd recommend that comments are arguments be well-formed and reasoned, and try to provide something new, so that we keep the signal high. Chat is a fine place to bounce an idea around, and then come back and write it up so we can keep the history (decision history is extremely valuable).
akashgurava and CathalMullan
Metadata
Metadata
Assignees
Labels
A-serverArea: server.Area: server.B-breaking-changeBlocked: this is an "API breaking change".Blocked: this is an "API breaking change".C-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.E-easyEffort: easy. A task that would be a great starting point for a new contributor.Effort: easy. A task that would be a great starting point for a new contributor.