Move Agent construction to new AgentBuilder.

In the process, rename set_foo methods to just foo, since methods on the
builder will always be setters.

Adds a new() method on ConnectionPool so it can be constructed directly
with the desired limits. Removes the setter methods on ConnectionPool
for those limits. This means that connection limits can only be set when
an Agent is built.

There were two tests that verify Send and Sync implementations, one for
Agent and one for Request. This PR moves the Request test to request.rs,
and changes both tests to more directly verify the traits. There may be
another way to do this, I'm not sure.
This commit is contained in:
Jacob Hoffman-Andrews
2020-10-17 23:07:53 -07:00
committed by Martin Algesten
parent 0f083a4436
commit 30162bf3bb
9 changed files with 211 additions and 262 deletions

View File

@@ -25,7 +25,7 @@ fn dribble_body_respond(mut stream: TcpStream, contents: &[u8]) -> io::Result<()
}
fn get_and_expect_timeout(url: String) {
let agent = Agent::default().build();
let agent = Agent::default();
let timeout = Duration::from_millis(500);
let resp = agent.get(&url).timeout(timeout).call().unwrap();
@@ -86,7 +86,7 @@ fn overall_timeout_reading_json() {
});
let url = format!("http://localhost:{}/", server.port);
let agent = Agent::default().build();
let agent = Agent::default();
let timeout = Duration::from_millis(500);
let resp = agent.get(&url).timeout(timeout).call().unwrap();