Description
Description
A general connection pool works by first narrowing down the available connections to a set of 'acceptable' connections. That is usually done by matching a few required attributes like host/port/TLS configuration. But usually, not all connections in the resulting set are equally desirable for a client.
For example, a client may prefer a connection that is on a particular EventLoop (or not on one). We might call it EventLoop (anti-)affinity. Other attributes like a geographical/DC/... (anti-)affinity or a load factor sound entirely plausible too.
Especially for proxies, EventLoop affinity is very important because they may need to proxy thousands of concurrent requests which shouldn't force thread switches for every request.
Additionally, (thanks @Lukasa for mentioning) a client may have an idea of how long they might be willing to wait for a 'better' connection.
API ideas
- One idea would be for the user of the connection pool to provide a scoring/sorting function about how much they like a certain connection. One idea would be
score(Connection) -> Double
(1.0: love it; 0.0: cannot use it) ororderConnectionAttractiveness(Connection, Connection) -> Bool