Skip to content

Align routing to spec #202

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

Merged
merged 8 commits into from
Feb 15, 2017
Merged

Conversation

lutovich
Copy link
Contributor

@lutovich lutovich commented Feb 6, 2017

This PR makes sure that bolt+routing works the same way as in other drivers. This means all errors and exceptional conditions are handled consistently.

It changes quite a bit of things around routing and introduces abstractions similar to Java driver:

  • RoutingTable
  • GetServersUtil
  • Rediscovery

Please read individual commit messages for more details.

Removed unused methods, simplified remove operation and added couple tests.
It contains 3 round robin arrays: routers, readers and writers. It also
contains an expiration timestamp which corresponds to `ttl` received from
`getServers` procedure call.
Previously it was mostly located in routing driver which owned the cluster
view and all logic to call `getServers` and interpret it's output/failures.

This introduces two new internal components:
 * `GetServersUtil` - responsible for calling `getServers` procedure and
 processing it's output
 * `Rediscovery` - responsible for fetching a routing table from the specified
 server

Routing driver now owns a routing table and an instance of rediscovery. It
uses the later one to update the routing table when needed.

Added dev dependency to lolex(https://github.com/sinonjs/lolex) to be able to
mock system time and test things better.
And add early validation of the session mode parameter.
Previously session and the underlying connection were not returned to the pool
after the rediscovery procedure. This happened because rediscovery session was
not initalized with an appropriate callback.

This commit fixes the problem by extracting the release callback code into a
function that gets called for both "normal" and "rediscovery" sessions.
Probably a cleaner way to fix this would be to move functionality into
`Session#close()` and make connection release itself to the pool. However
this resulted into lots of non-trivial changes and thus should go into a
separate PR.
@technige technige merged commit aff3b1d into neo4j:1.1 Feb 15, 2017
@lutovich lutovich deleted the 1.1-align-routing-to-spec branch March 10, 2017 00:28
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