File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ class Ydb
88
88
*/
89
89
protected $ discoveryInterval = 60 ;
90
90
91
+ protected $ triedDiscovery = false ;
92
+
91
93
/**
92
94
* @param array $config
93
95
* @param LoggerInterface|null $logger
@@ -162,16 +164,21 @@ public function meta(): array
162
164
*/
163
165
public function discover ()
164
166
{
165
- $ endpoints = $ this ->discovery ()->listEndpoints ();
166
- if (!empty ($ endpoints ))
167
- {
168
- $ this ->cluster ()->sync ((array )$ endpoints );
169
- $ clusterEndpoints = array_map (function ($ e ){
170
- return $ e ["address " ].": " .$ e ["port " ];
167
+ if ($ this ->triedDiscovery ) return ;
168
+ $ this ->triedDiscovery = true ;
169
+ try {
170
+ $ endpoints = $ this ->discovery ()->listEndpoints ();
171
+ if (!empty ($ endpoints )) {
172
+ $ this ->cluster ()->sync ((array )$ endpoints );
173
+ $ clusterEndpoints = array_map (function ($ e ) {
174
+ return $ e ["address " ] . ": " . $ e ["port " ];
171
175
}, (array )$ endpoints );
172
- if (!array_search ($ this ->endpoint , $ clusterEndpoints )){
173
- $ this ->endpoint = $ clusterEndpoints [array_rand ($ clusterEndpoints )];
176
+ if (!array_search ($ this ->endpoint , $ clusterEndpoints )) {
177
+ $ this ->endpoint = $ clusterEndpoints [array_rand ($ clusterEndpoints )];
178
+ }
174
179
}
180
+ } finally {
181
+ $ this ->triedDiscovery = false ;
175
182
}
176
183
}
177
184
You can’t perform that action at this time.
0 commit comments