Skip to content

Read without writer #158

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 6 commits into from
Apr 28, 2017
Merged

Read without writer #158

merged 6 commits into from
Apr 28, 2017

Conversation

zhenlineo
Copy link
Contributor

Based on #157 supporting routing context in bolt uri

context = {}
parameters = [x for x in query.split('&') if x]
for keyValue in parameters:
pair = keyValue.split('=')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key, _, value = keyValue.partition("=")
if not key or not value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -56,6 +56,8 @@ def __init__(self, uri, **config):
# will carry out DNS resolution, leading to the possibility that
# the connection pool may contain multiple IP address keys, one for
# an old address and one for a new address.
if SocketAddress.parse_routing_context(uri):
raise ValueError("Routing parameters are not supported with scheme 'bolt'. Given URI: '%s'." % uri)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no Routing

""" Indicator for whether routing information is still usable.
"""
expired = self.last_updated_time + self.ttl <= self.timer()
return not expired and len(self.routers) > 1 and self.readers and self.writers
has_server_for_mode = (access_mode == READ_ACCESS and self.readers) or (access_mode == WRITE_ACCESS and self.writers)
return not expired and len(self.routers) >= 1 and has_server_for_mode
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and self.routers

if ServerVersion.from_str(connection.server.version).at_least_version(3, 2):
return self.call_get_routing_table, {self.get_routing_table_param: self.routing_context}
else:
return self.call_get_servers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return self.call_get_servers, {}

@@ -169,8 +182,9 @@ def fetch_routing_info(self, address):
if routing support is broken
"""
try:
with BoltSession(lambda _: self.acquire_direct(address)) as session:
return list(session.run("CALL %s" % self.routing_info_procedure))
connection = self.acquire_direct(address)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connections = [None]

def connector(_):
connection = self.acquire_direct(address)
connections[0] = connection
return connection

with BoltSession(connector) as session:
last_connection = connections[0]

# None of the routers have been successful, so just fail
raise ServiceUnavailable("Unable to retrieve routing information")

def refresh_routing_table(self):
def ensure_routing_table(self, access_mode):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensure_routing_table_is_fresh

@zhenlineo zhenlineo force-pushed the 1.3-read-without-writer branch 3 times, most recently from 0e3d67e to 1cc9ac8 Compare April 27, 2017 15:35
@zhenlineo zhenlineo force-pushed the 1.3-read-without-writer branch from 1cc9ac8 to fe7554e Compare April 27, 2017 15:54
@zhenlineo zhenlineo force-pushed the 1.3-read-without-writer branch from 87677b0 to 3cb094a Compare April 28, 2017 12:40
@zhenlineo zhenlineo merged commit ed27f5e into neo4j:1.3 Apr 28, 2017
@zhenlineo zhenlineo deleted the 1.3-read-without-writer branch April 28, 2017 14:08
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.

1 participant