Skip to content

Commit

Permalink
Add configuration for Redis cluster support (#166)
Browse files Browse the repository at this point in the history
* Add configuration for Redis clusters

* Update configuration to specify Redis connection data

* Remove unused config lines
  • Loading branch information
MartyHimmel authored Apr 22, 2024
1 parent 4a08256 commit 78d8db3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions config/reverb.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
'scaling' => [
'enabled' => env('REVERB_SCALING_ENABLED', false),
'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
'server' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'port' => env('REDIS_PORT', '6379'),
'password' => env('REDIS_PASSWORD'),
'database' => env('REDIS_DB', '0'),
],
],
'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15),
Expand Down
5 changes: 3 additions & 2 deletions src/Servers/Reverb/Publishing/RedisPubSubProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class RedisPubSubProvider implements PubSubProvider
public function __construct(
protected RedisClientFactory $clientFactory,
protected PubSubIncomingMessageHandler $messageHandler,
protected string $channel
protected string $channel,
protected array $server = []
) {
//
}
Expand Down Expand Up @@ -85,7 +86,7 @@ public function publish(array $payload): PromiseInterface
*/
protected function redisUrl(): string
{
$config = Config::get('database.redis.default');
$config = empty($this->server) ? Config::get('database.redis.default') : $this->server;

[$host, $port, $protocol, $query] = [
$config['host'],
Expand Down
3 changes: 2 additions & 1 deletion src/Servers/Reverb/ReverbServerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function register(): void
$this->app->singleton(PubSubProvider::class, fn ($app) => new RedisPubSubProvider(
$app->make(RedisClientFactory::class),
$app->make(PubSubIncomingMessageHandler::class),
$this->config['scaling']['channel'] ?? 'reverb'
$this->config['scaling']['channel'] ?? 'reverb',
$this->config['scaling']['server'] ?? []
));
}

Expand Down

0 comments on commit 78d8db3

Please sign in to comment.