Make Relay work with Redis cluster (#1397)

This commit is contained in:
Jiří Bok
2023-09-13 18:59:50 +02:00
committed by Till Krüss
parent 8e66c20dc0
commit c83ffa43d8
17 changed files with 397 additions and 22 deletions
+22 -4
View File
@@ -158,6 +158,18 @@ class RelayConnection extends AbstractConnection
return $this->client;
}
/**
* {@inheritdoc}
*/
public function getIdentifier()
{
try {
return $this->client->endpointId();
} catch (RelayException $ex) {
return parent::getIdentifier();
}
}
/**
* {@inheritdoc}
*/
@@ -177,7 +189,13 @@ class RelayConnection extends AbstractConnection
? $this->client->{$name}(...$command->getArguments())
: $this->client->rawCommand($name, ...$command->getArguments());
} catch (RelayException $ex) {
throw $this->onCommandError($ex, $command);
$exception = $this->onCommandError($ex, $command);
if ($exception instanceof ErrorResponseInterface) {
return $exception;
}
throw $exception;
}
}
@@ -189,15 +207,15 @@ class RelayConnection extends AbstractConnection
$code = $exception->getCode();
$message = $exception->getMessage();
if (strpos($message, 'RELAY_ERR_IO')) {
if (strpos($message, 'RELAY_ERR_IO') !== false) {
return new ConnectionException($this, $message, $code, $exception);
}
if (strpos($message, 'RELAY_ERR_REDIS')) {
if (strpos($message, 'RELAY_ERR_REDIS') !== false) {
return new ServerException($message, $code, $exception);
}
if (strpos($message, 'RELAY_ERR_WRONGTYPE') && strpos($message, "Got reply-type 'status'")) {
if (strpos($message, 'RELAY_ERR_WRONGTYPE') !== false && strpos($message, "Got reply-type 'status'") !== false) {
$message = 'Operation against a key holding the wrong kind of value';
}