Hands out connections to origins, sharing them while they are in use.
More...
#include <cpp/a11/net/http/connection_pool.h>
Hands out connections to origins, sharing them while they are in use.
- Warning
options.deadline is ignored: a connection-wide deadline set by one request would cut short every other request sharing it. Bound an exchange by awaiting it with a deadline and cancelling its stream, not by telling the connection when to die.
◆ Acquire()
Borrows a connection to origin, dialling one if needed.
A live connection to the same origin with compatible options is joined rather than replaced. A dial already in progress is joined too, so a burst of requests to a cold origin opens one socket instead of several.
- Parameters
-
| origin | Parsed URL; its scheme, host and port select the peer, and the scheme decides TLS. |
| options | Transport settings. Their TLS and protocol fields are part of the pool key, since a connection trusting different roots is a different peer. deadline is ignored (see the class note). |
- Returns
- An awaitable resolving to the lease, or the dial's error.
◆ AcquireUnshared()
Dials a connection nobody else will be given, and leases it.
For a caller that asked not to share – a request with client certificates of its own, or one whose timing must not be affected by anyone else's traffic. It is closed when the last copy of the lease goes, as a pooled one is; the only difference is that no second caller is ever handed it.
- Parameters
-
| origin | Parsed URL naming the peer; its scheme decides TLS. |
| options | Transport settings. deadline is ignored, as in Acquire(). |
- Returns
- An awaitable resolving to the lease, or the dial's error.
◆ Create()
Creates an independent pool.
◆ Shared()
The process-wide pool.
What a caller wants by default: two unrelated parts of a program fetching from the same peer at the same moment should share the connection, and neither should have to have been told about the other.
◆ size()
| size_t a11::net::HttpConnectionPool::size |
( |
| ) |
const |
- Returns
- How many connections are currently live. For tests.
The documentation for this class was generated from the following files: