-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Support Redis Cluster #40155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Messenger\Bridge\Redis\Transport; | ||
|
||
/** | ||
* Allow to delay connection to Redis Cluster. | ||
* | ||
* @author Johann Pardanaud <johann@pardanaud.com> | ||
* | ||
* @internal | ||
*/ | ||
class RedisClusterProxy | ||
{ | ||
private $redis; | ||
private $initializer; | ||
private $ready = false; | ||
|
||
public function __construct(?\RedisCluster $redis, \Closure $initializer) | ||
{ | ||
$this->redis = $redis; | ||
$this->initializer = $initializer; | ||
} | ||
|
||
public function __call(string $method, array $args) | ||
{ | ||
if (!$this->ready) { | ||
$this->redis = $this->initializer->__invoke($this->redis); | ||
$this->ready = true; | ||
} | ||
|
||
return $this->redis->{$method}(...$args); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,10 @@ public function __construct(\Redis $redis, \Closure $initializer) | |
|
||
public function __call(string $method, array $args) | ||
{ | ||
$this->ready ?: $this->ready = $this->initializer->__invoke($this->redis); | ||
if (!$this->ready) { | ||
$this->redis = $this->initializer->__invoke($this->redis); | ||
$this->ready = true; | ||
} | ||
Comment on lines
+36
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe Im missing something, but can you tell me why this was changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's because the signature of the initializer has changed (this is fine because this is internal) |
||
|
||
return $this->redis->{$method}(...$args); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.