Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nats Connection Pooling #2554

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

calmera
Copy link
Collaborator

@calmera calmera commented Apr 30, 2024

Use a singleton pool to track connections being made to nats.

Connections are tracked based on an advanced pool_key parameter. Components which share the same value for this parameter will also share the same connection.

The pool will do reference tracking; for this each component has been equiped with a pcid field which holds a UUID upon instantiation. When a component retrieves a connection from the pool, its picd is being added to the references. Components are required to release their connections and code has been adapted for them to do so. When releasing a connection, the reference will be removed from the connection and if no references are left, the connection will be closed and removed from the pool.

Use a singleton pool to track connections being made to nats.
Connections are tracked based on their Url + Nats Options, so defining
different options will still result in multiple connections existing.
However, nats components using the same url and nats options will reuse
the connection.

Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
@calmera calmera requested a review from Jeffail as a code owner April 30, 2024 12:54
Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
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.

None yet

1 participant