-
Notifications
You must be signed in to change notification settings - Fork 46
Implement reconnection strategy class #109
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
Conversation
ff0f4af
to
46beffb
Compare
|
|
46beffb
to
6d62982
Compare
tarantool/__init__.py
Outdated
''' | ||
Create a connection to the mesh of Tarantool servers. | ||
|
||
:param str addrs: A map of server hostname or IP-address and a port. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description is a bit unprecise: it is a tuple / a list of maps.
tarantool/mesh_connection.py
Outdated
reconnect_delay=RECONNECT_DELAY, | ||
connect_now=True, | ||
encoding=ENCODING_DEFAULT, | ||
Strategy=RoundRobinStrategy): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is unusual to start a parameter name and / or a class field name from an uppercase letter in Python. From the other side, it is a reference to a class, so I don't sure what is better to do.
testclient.py
Outdated
@@ -0,0 +1,23 @@ | |||
#!/usr/bin/env python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add and then remove it.
test/cluster-py/multi.test.py
Outdated
import time | ||
import yaml | ||
from lib.tarantool_server import TarantoolServer | ||
from tarantool import MeshConnection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports do not work for me.
test/cluster-py/multi.test.py
Outdated
while True: | ||
try: | ||
x = con.ping() | ||
print 'ping Ok' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to use python-3-style prints, because it is universal.
test/cluster-py/replica.lua
Outdated
@@ -0,0 +1,13 @@ | |||
#!/usr/bin/env tarantool | |||
box_cfg_done = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not used.
test/cluster-py/suite.ini
Outdated
[default] | ||
core = tarantool | ||
script = master.lua | ||
description = tarantool/box, replication |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description seems to be not about the suite we have here.
6d62982
to
63436b5
Compare
Extend base Connection class to support a list of nodes and an optional Strategy parameter to choose next item from this list. Add built-in reconnect strategy class based on Round-Robin alg. @params: - addrs, list of maps {'host':(HOSTNAME|IP_ADDR), 'port':PORT}. Return next connection or an error if all URIs are unavailable. Closes #106
e6634a3
to
fb256f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments re testing are below.
I think we can setup CI with make install
for now (and merge the PR) and file a follow up issue to use the connector from the repository during make test
/ cd test && ./test-run.py
.
test/cluster-py/multi.test.py
Outdated
host, port = addr.split(':') | ||
addrs.append({'host': host, 'port': int(port)}) | ||
|
||
thread = Thread(target=check_cluster, args=(addrs, )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to create purely sequencial test and don't lean on timings. Like so (schematically):
setup instances
setup mesh connection
perform select
stop instance 1
perform select
stop instance 2
start instance 1
perform select
stop instance 1
perform select
fb256f1
to
ca7dc5b
Compare
test/cluster-py/replica.lua
Outdated
local SOCKET_DIR = require('fio').cwd() | ||
|
||
local function instance_uri(instance_id) | ||
return SOCKET_DIR..'/autobootstrap'..instance_id..'.sock'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why replica? Why autobootstrap? Why multi?
I think we should adjust naming.
I'll ok after:
Also I think we can use default server as the first instance in the test (and setup one more). Please, proceed with that and merge. I don't think I should look into that again. |
ca7dc5b
to
436218d
Compare
Extend base Connection class to support a list of nodes and an
optional Strategy parameter to choose next item from this list.
Add built-in reconnect strategy class based on Round-Robin alg.
@params:
Return next connection or an error if all URIs are unavailable.
Closes #106