neo4j / neo4j-javascript-driver

Neo4j Bolt driver for JavaScript
https://neo4j.com/docs/javascript-manual/current/
Apache License 2.0
853 stars 148 forks source link

Hide protocol object behind the Connection #1139

Closed bigmontz closed 1 year ago

bigmontz commented 1 year ago

The connection in the driver is exposing the protocol object, which is not great. Improve this part of the code can be done by make the connection object have methods to do high level requests to the server.

List of calls the core driver does using the protocol, by passing the connection:

Methods is present in the Connection interface (used by core in bold):

So, isOpen, resetAndFlush and hasOngoingObservableRequests are the methods which will stay in the connection along with the new methods. The method release will move the a Releasable interface, which will be composed with Connection when returning the connection from the provider.

The Releasable interface is also defined to enable the ConnectionProvider returns a connection which can be released back to the pool.

Internally, bolt-connection can keep exposing the internal of the connection outside the connection in a first moment. The full encapsulation of the protocol should be done in the next phase of refactoring.