Skip to content

Commit

Permalink
Add configuration for Redis clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyHimmel committed Apr 19, 2024
1 parent 4a08256 commit e4bed34
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/reverb.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'scaling' => [
'enabled' => env('REVERB_SCALING_ENABLED', false),
'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
'cluster_enabled' => env('REVERB_SCALING_CLUSTER_ENABLED', false),
],
'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 bool $clusterMode = false
) {
//
}
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 = Config::get($this->clusterMode ? 'database.redis.clusters.default.0' : 'database.redis.default');

[$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']['cluster_enabled'] ?? false
));
}

Expand Down

0 comments on commit e4bed34

Please sign in to comment.