A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::net::HttpConnectionPool Class Reference

Hands out connections to origins, sharing them while they are in use. More...

#include <cpp/a11/net/http/connection_pool.h>

Inheritance diagram for a11::net::HttpConnectionPool:
[legend]

Public Member Functions

a11::Future< HttpConnectionLease > Acquire (const ParsedUrl &origin, Http2Options options)
 Borrows a connection to origin, dialling one if needed.
 
size_t size () const
 

Static Public Member Functions

static std::shared_ptr< HttpConnectionPool > Create ()
 Creates an independent pool.
 
static const std::shared_ptr< HttpConnectionPool > & Shared ()
 The process-wide pool.
 
static a11::Future< HttpConnectionLease > AcquireUnshared (const ParsedUrl &origin, Http2Options options)
 Dials a connection nobody else will be given, and leases it.
 

Detailed Description

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.

Member Function Documentation

◆ Acquire()

a11::Future< HttpConnectionLease > a11::net::HttpConnectionPool::Acquire ( const ParsedUrl &  origin,
Http2Options  options 
)

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
originParsed URL; its scheme, host and port select the peer, and the scheme decides TLS.
optionsTransport 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()

a11::Future< HttpConnectionLease > a11::net::HttpConnectionPool::AcquireUnshared ( const ParsedUrl &  origin,
Http2Options  options 
)
static

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
originParsed URL naming the peer; its scheme decides TLS.
optionsTransport settings. deadline is ignored, as in Acquire().
Returns
An awaitable resolving to the lease, or the dial's error.

◆ Create()

std::shared_ptr< HttpConnectionPool > a11::net::HttpConnectionPool::Create ( )
static

Creates an independent pool.

◆ Shared()

const std::shared_ptr< HttpConnectionPool > & a11::net::HttpConnectionPool::Shared ( )
static

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: