@@ -104,7 +104,7 @@ class MeshConnection(Connection):
104
104
end
105
105
'''
106
106
107
- def __init__ (self , host , port ,
107
+ def __init__ (self , host = None , port = None ,
108
108
user = None ,
109
109
password = None ,
110
110
socket_timeout = SOCKET_TIMEOUT ,
@@ -114,23 +114,29 @@ def __init__(self, host, port,
114
114
encoding = ENCODING_DEFAULT ,
115
115
call_16 = False ,
116
116
connection_timeout = CONNECTION_TIMEOUT ,
117
- cluster_list = None ,
117
+ addrs = None ,
118
118
strategy_class = RoundRobinStrategy ,
119
119
get_nodes_function_name = None ,
120
120
nodes_refresh_interval = DEFAULT_CLUSTER_DISCOVERY_DELAY_MILLIS ):
121
121
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' ]})
128
131
129
- self .strategy = strategy_class (addrs )
130
132
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
+
134
140
self .get_nodes_function_name = get_nodes_function_name
135
141
self .nodes_refresh_interval = nodes_refresh_interval
136
142
self .last_nodes_refresh = time .time ()
0 commit comments