Skip to content

Conversation

@shonfeder
Copy link
Contributor

WIP

This is on top of #1126

I am still finalizing the API and the documentation, will update once the prerequisites are merged and this is cleaned up.

shonfeder and others added 10 commits November 13, 2025 08:46
Includes an example application that exercises the functionality.

Co-authored-by: Marek Kubica <marek@tarides.com>
Applies a patch provided by @art-w removing showing the way out of the
existential type.

Co-authored-by: ArthurW <arthur@tarides.com>
We will need to share this between the connection cache and the client
front end

Also refines the Client_connection API
We will need access to the host addresses before sockets are created,
since each connection pool is looked up based on the address
Hashtbl.add lru addr conns;
conns
in
Eio.Pool.use conns (fun c -> f c.conn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the Pool is helping or not: since you already have a Mutex to protect the Hashtbl, it looks like the hashtable could store lists of available connections from which you could pick one (or create a new one when none are available + lru logic to close another if going over budget).
Then you would be able to avoid Pool.use and its callback, in favor of a more direct style (but you would still want to protect that connection by using the caller switch, such that it is added back to the Hashtbl once the user is done with it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mutex protects adding/removing new pools. But we don't want to lock the entire table when a single socket is being used. AFAIU, the Pool is doing work here to synchronize work dispatched across the sockets in a single pool and to take care of expiring them on the configurable timeout. We could implement a resource pool on a list, ensuring that no 2 calls can get access to the same socket, and that we expire old connections after a timeout, but then I think I will have re-implemented a custom pool?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants