26 lines
596 B
PHP
26 lines
596 B
PHP
<?php
|
|
|
|
namespace Toalett\Redis\Timeseries;
|
|
|
|
use Predis\Client;
|
|
use Toalett\Redis\Timeseries\Exception\DatabaseException;
|
|
use Toalett\Redis\Timeseries\Protocol\Command\Command;
|
|
|
|
final class CommandBus
|
|
{
|
|
private Client $client;
|
|
|
|
public function __construct(Client $client)
|
|
{
|
|
$this->client = $client;
|
|
}
|
|
|
|
public function dispatch(Command $command): void
|
|
{
|
|
$response = $this->client->executeRaw($command->toRawCommand());
|
|
if (is_string($response) && 0 !== strpos($response, 'OK')) {
|
|
throw new DatabaseException($response);
|
|
}
|
|
}
|
|
}
|