feat(client): impl Sync for Client
Connector::connect already used &self, and so would require synchronization to be handled per connector anyway. Adding Sync to the Client allows users to setup config for a Client once, such as using a single connection Pool, and then making requests across multiple threads. Closes #254 BREAKING CHANGE: Connectors and Protocols passed to the `Client` must now also have a `Sync` bounds, but this shouldn't break default usage.
This commit is contained in:
@@ -20,7 +20,7 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
let mut client = Client::new();
|
||||
let client = Client::new();
|
||||
|
||||
let mut res = client.get(&*url)
|
||||
.header(Connection::close())
|
||||
|
||||
@@ -21,7 +21,7 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
let mut client = Client::with_protocol(h2::new_protocol());
|
||||
let client = Client::with_protocol(h2::new_protocol());
|
||||
|
||||
// `Connection: Close` is not a valid header for HTTP/2, but the client handles it gracefully.
|
||||
let mut res = client.get(&*url)
|
||||
|
||||
Reference in New Issue
Block a user