Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
make both options redis_sentinel and sentinel_master available everyw…
…here
  • Loading branch information
xabbuh committed Dec 4, 2023
commit 7c1bfcf0ae3562012954c0d04b42828a050f27f0
5 changes: 5 additions & 0 deletions src/Symfony/Component/Cache/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.1
---

* Add option `sentinel_master` as an alias for `redis_sentinel`

7.0
---

Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Cache/Traits/RedisTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra

$params += $query + $options + self::$defaultConnectionOptions;

if (isset($params['redis_sentinel']) && isset($params['sentinel_master'])) {
throw new InvalidArgumentException('Cannot use both "redis_sentinel" and "sentinel_master" at the same time.');
}

$params['redis_sentinel'] ??= $params['sentinel_master'] ?? null;

if (isset($params['redis_sentinel']) && !class_exists(\Predis\Client::class) && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) {
throw new CacheException('Redis Sentinel support requires one of: "predis/predis", "ext-redis >= 5.2", "ext-relay".');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ public function testConnectionClaimAndRedeliver()
$connection->ack($message['id']);
}

public function testSentinel()
/**
* @dataProvider
*/
public function testSentinel(string $sentinelOptionName)
{
if (!$hosts = getenv('REDIS_SENTINEL_HOSTS')) {
$this->markTestSkipped('REDIS_SENTINEL_HOSTS env var is not defined.');
Expand All @@ -234,7 +237,7 @@ public function testSentinel()

$connection = Connection::fromDsn($dsn,
['delete_after_ack' => true,
'sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?: null,
$sentinelOptionName => getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?: null,
], $this->redis);

$connection->add('1', []);
Expand All @@ -249,6 +252,12 @@ public function testSentinel()
$connection->cleanup();
}

public function sentinelOptionNames(): iterable
{
yield 'redis_sentinel';
yield 'sentinel_master';
}

public function testLazySentinel()
{
$connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ public function __construct(array $options, \Redis|Relay|\RedisCluster $redis =
$host = $options['host'];
$port = $options['port'];
$auth = $options['auth'];
$sentinelMaster = $options['sentinel_master'];

if (isset($options['redis_sentinel']) && isset($options['sentinel_master'])) {
throw new InvalidArgumentException('Cannot use both "redis_sentinel" and "sentinel_master" at the same time.');
}

$sentinelMaster = $options['sentinel_master'] ?? $options['redis_sentinel'] ?? null;

if (null !== $sentinelMaster && !class_exists(\RedisSentinel::class) && !class_exists(Sentinel::class)) {
throw new InvalidArgumentException('Redis Sentinel support requires ext-redis>=5.2, or ext-relay.');
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Messenger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
7.1
---

* Add option `redis_sentinel` as an alias for `sentinel_master`
* Add `--all` option to the `messenger:consume` command

7.0
Expand Down