Skip to content
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

Implementing PhpRedis client #36

Open
wants to merge 18 commits into
base: 2.x
Choose a base branch
from
Open

Conversation

jeffreyzant
Copy link

@jeffreyzant jeffreyzant commented Apr 12, 2021

This PR implements the PhpRedis client for Redis Sentinel. It wraps all methods with a retryOnFailure and creates a new Redis client when the connection fails.

@jeffreyzant jeffreyzant force-pushed the phpredis branch 4 times, most recently from 7897b9e to 028b794 Compare April 13, 2021 13:04
@jeffreyzant jeffreyzant force-pushed the phpredis branch 4 times, most recently from 83b0947 to 11a7bc9 Compare April 14, 2021 10:23
@jeffreyzant jeffreyzant changed the title WIP Implementing Phpredis client Implementing Phpredis client Apr 14, 2021
@jeffreyzant jeffreyzant changed the title Implementing Phpredis client Implementing PhpRedis client Apr 14, 2021
@jeffreyzant jeffreyzant marked this pull request as ready for review April 14, 2021 14:02
Copy link

@Namoshek Namoshek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this looks very promising and exactly what I need for an upcoming move to Kubernetes. Thanks for putting so much effort into making this a thing! Hopefully, the maintainer is going to be able to have a look at this soon.

src/Configuration/HostNormalizer.php Outdated Show resolved Hide resolved
src/Connections/PhpRedisConnection.php Show resolved Hide resolved
src/Connectors/PhpRedisConnector.php Outdated Show resolved Hide resolved
src/Connectors/PhpRedisConnector.php Outdated Show resolved Hide resolved
src/Connectors/PhpRedisConnector.php Outdated Show resolved Hide resolved
src/Connectors/PhpRedisConnector.php Outdated Show resolved Hide resolved
src/Connectors/PhpRedisConnector.php Show resolved Hide resolved

// The default amount of time (in milliseconds) that the client waits before
// retrying the connection attempt.
'connector_retry_wait' => 1000,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do these configuration paramters play together with retry_limit and retry_wait? Would it be possible to allow the PhpRedisConnection to reuse the connector logic (and retry configuration) of PhpRedisConnector?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These settings allow for a different configuration on first connection. So the normal retry_limit and retry_wait are used for reconnecting after a failure. The connector_ options are used when creating the connection for the first time.

I've combined some of the retry logic, but I can't seem to find a way to simplify this. Maybe you have some ideas about it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the settings are fine, just a bit hard to understand in combination with the other ones (which have quite similar names too). Explaining their difference from the similar named settings is probably all you can do at this point.

src/Connectors/PhpRedisConnector.php Outdated Show resolved Hide resolved
src/Connectors/PhpRedisConnector.php Show resolved Hide resolved
@jeffreyzant
Copy link
Author

@Namoshek thanks for your reply, I will try to work on your comments next week. We are already using this PR in our Kubernetes cluster :)

@krowinski
Copy link

Hi! Any ETA when this will be merge to main tree and tag released ?

@L3o-pold
Copy link

L3o-pold commented May 2, 2022

@cyrossignol can we see this merged

public function connect(array $servers, array $options = [ ])
{
// Set the initial Sentinel servers.
$this->servers = array_map(function ($server) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should extract the options key before setting the servers or it can result trying to connect to the wrong hostname here: https://github.com/monospice/laravel-redis-sentinel-drivers/pull/36/files#diff-3bf85f59585710cebd9ae7787d8b7ffb7df273ce8ffe2e72053ef96b4bb81ccaR157


// Create a client by calling the Sentinel servers
$connector = function () use ($options) {
return $this->createClientWithSentinel($options);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are using $options instead of $clientOpts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants