Skip to content

Commit 04684ab

Browse files
authored
Fixed discovery on exception
Fixed discovery on exception
2 parents e667f7f + a5b9bdc commit 04684ab

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* fixed discovery on exception
12
* fixed logger in EnvironCredentials
23

34
# 1.8.1

src/Traits/RequestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected function handleGrpcStatus($service, $method, $status)
179179
}catch (\Exception $e){}
180180
}
181181
$endpoint = $this->ydb->endpoint();
182-
if ($this->ydb->needDiscovery()){
182+
if ($this->ydb->needDiscovery() && count($this->ydb->cluster()->all()) > 0){
183183
$endpoint = $this->ydb->cluster()->all()[array_rand($this->ydb->cluster()->all())]->endpoint();
184184
}
185185
$this->client = new $this->client($endpoint,[

src/Ydb.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,24 @@ public function __construct($config = [], LoggerInterface $logger = null)
107107
$this->logger = new NullLogger();
108108
}
109109

110+
$this->retry = new Retry($this->logger);
111+
110112
if(isset($config['credentials'])){
111113
$this->iam_config['credentials'] = $config['credentials'];
112114
$config['credentials']->setLogger($this->logger());
113115
}
114116

115117
if (!empty($config['discovery']))
116118
{
119+
$this->discover = true;
117120
if (isset($config['discoveryInterval'])){
118121
$this->discoveryInterval = $config['discoveryInterval'];
119122
}
120-
$this->discover();
121-
}
122123

123-
$this->retry = new Retry($this->logger);
124+
$this->retry(function (){
125+
$this->discover();
126+
}, true);
127+
}
124128

125129
$this->logger()->info('YDB: Initialized');
126130
}

0 commit comments

Comments
 (0)