Skip to content

Commit 511cf2a

Browse files
authored
Merge branch 'main' into fix-exception-not-foud
2 parents dad663d + 04684ab commit 511cf2a

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
* add class exist check in RequestTrait
1+
2+
* fixed discovery on exception
3+
* fixed logger in EnvironCredentials
24

35
# 1.8.1
46

src/Auth/EnvironCredentials.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,14 @@ public function getName(): string
3737
{
3838
return $this->auth->getName();
3939
}
40+
41+
public function logger()
42+
{
43+
return $this->auth->logger();
44+
}
45+
46+
public function setLogger($logger)
47+
{
48+
$this->auth->setLogger($logger);
49+
}
4050
}

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)