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

Close or disconnect connection #236

Open
tomswinkels opened this issue Oct 23, 2024 · 3 comments
Open

Close or disconnect connection #236

tomswinkels opened this issue Oct 23, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@tomswinkels
Copy link

Hi,

Is there an option to close the connection?

Like $client->disconnect(); ?

In the bolt client, there is an option for it ->

$this->connection->disconnect();

@tomswinkels tomswinkels added the enhancement New feature or request label Oct 23, 2024
@transistive
Copy link
Collaborator

transistive commented Oct 23, 2024

Hello @tomswinkels,

Thank you for the question. @exaby73 and I have been discussing this very heavily and are busy implementing it properly. He is sick today, but we hope to circle back to this on Friday!

@tomswinkels
Copy link
Author

Any update @transistive and @exaby73 ?

@transistive
Copy link
Collaborator

Hello @tomswinkels,

We have thoroughly discussed this as the connection logic is quite complicated.

In more general terms these are some relevant factors:

  • The client does not have a single connection, but rather a collection of drivers.
  • A driver holds a connection pool that dynamically creates connections as required.
  • The session object borrows a connection every time it runs a transaction
  • The only object actually holding a connection is a Transaction object, which is the only place we can theoretically expose it.
  • The new PR with logging actually silently included a closeConnections method here
    public function closeConnections(): void
    . This actually clears the routing tables connections but is very dangerous as it will break any running transactions.

A long story short: we ended up in a long theoretical discussion of how this disconnecting of the connections would even be needed.

It seems like a valuable learning opportunity for all of us to see how this need arose, because under the current architecture exposing a single connection in the client, driver or session object is simply impossible.

I'll ping you in the internal slack to discuss further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants