typedb / typedb-driver-python

TypeDB Driver for Python
https://typedb.com
Apache License 2.0
67 stars 24 forks source link

Bind Cluster sessions to single server nodes, and add naive load balancing #183

Closed alexjpwalker closed 3 years ago

alexjpwalker commented 3 years ago

What is the goal of this PR?

Previously, each Cluster session would lazily create Core sessions on-demand as Transactions were opened. This delegated too much responsibility to the Transaction. Now, each Cluster session is bound to a single server node, which may be a primary or a secondary node depending on the Options passed to the Session.

We also select secondary nodes in a fairer, more balanced way; the server indicates which node is its first preference for secondary sessions, and the client tries to obey the server's decision, with fallback to backup nodes only in the event of a failure.

What are the changes implemented in this PR?