Closed
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).