Skip to content

Commit bfbc164

Browse files
Fix compat with init mesh builder.
Fix compat Mesh class with original Connection.
1 parent d0d456f commit bfbc164

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

tarantool/mesh_connection.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class MeshConnection(Connection):
104104
end
105105
'''
106106

107-
def __init__(self, host, port,
107+
def __init__(self, host=None, port=None,
108108
user=None,
109109
password=None,
110110
socket_timeout=SOCKET_TIMEOUT,
@@ -114,23 +114,29 @@ def __init__(self, host, port,
114114
encoding=ENCODING_DEFAULT,
115115
call_16=False,
116116
connection_timeout=CONNECTION_TIMEOUT,
117-
cluster_list=None,
117+
addrs=None,
118118
strategy_class=RoundRobinStrategy,
119119
get_nodes_function_name=None,
120120
nodes_refresh_interval=DEFAULT_CLUSTER_DISCOVERY_DELAY_MILLIS):
121121

122-
addrs = [{"host": host, "port": port}]
123-
if cluster_list:
124-
for i in cluster_list:
125-
if i["host"] == host or i["port"] == port:
126-
continue
127-
addrs.append(i)
122+
addrs_list = []
123+
124+
if host and port:
125+
addrs_list.append({'host':host, 'port':port})
126+
127+
if addrs:
128+
for addr in addrs:
129+
if 'host' in addr and 'port' in addr:
130+
addrs_list.append({'host': addr['host'], 'port': addr['port']})
128131

129-
self.strategy = strategy_class(addrs)
130132
self.strategy_class = strategy_class
131-
addr = self.strategy.getnext()
132-
host = addr['host']
133-
port = addr['port']
133+
self.strategy = strategy_class(addrs_list)
134+
135+
if not host and not port:
136+
addr = self.strategy.getnext()
137+
host = addr['host']
138+
port = addr['port']
139+
134140
self.get_nodes_function_name = get_nodes_function_name
135141
self.nodes_refresh_interval = nodes_refresh_interval
136142
self.last_nodes_refresh = time.time()

0 commit comments

Comments
 (0)