Skip to content

[Messenger] Document DSN format for Redis Cluster #14956

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

Merged
merged 1 commit into from
May 7, 2021

Conversation

nesk
Copy link
Contributor

@nesk nesk commented Feb 11, 2021

Document Redis Cluster support for the Messenger component.

Related to symfony/symfony#40155

@OskarStark OskarStark added the Waiting Code Merge Docs for features pending to be merged label Feb 12, 2021
@carsonbot carsonbot added this to the next milestone Feb 12, 2021
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Apr 13, 2021
This PR was squashed before being merged into the 5.3-dev branch.

Discussion
----------

[Messenger] Support Redis Cluster

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #38264
| License       | MIT
| Doc PR        | symfony/symfony-docs#14956

This PR brings support for Redis Cluster in the Messenger component:

- The first commit _Support RedisCluster instance_ allows to pass a `RedisCluster` object when instanciating the `Connection` class, which brings support for Redis Cluster without any friction.
- The second commit _Support multiple hosts DSN for Redis Cluster_ is more opiniated and brings a DSN format to configure a Redis Cluster from `config/packages/messenger.yaml`.

Instanciating `Connection` with a `RedisCluster` object:

```php
$redis = new \RedisCluster(null, ['host-01:6379', 'host-02:6379', 'host-03:6379', 'host-04:6379']);
$connection = new Connection([], [], [], $redis);
```

Configuring a Redis Cluster from YAML:

```yaml
// config/packages/messenger.yaml

framework:
    messenger:
            metadata:
                default: 'redis://host-01:6379,redis://host-02:6379,redis://host-03:6379'
                lazy: 'redis://host-01:6379?lazy=1,redis://host-02:6379,redis://host-03:6379'

                # Configuration will be `lazy = true` and `auto_setup = true`
                multipleConfig: 'redis://host-01:6379?lazy=1&auto_setup=false,redis://host-02:6379,redis://host-03:6379?auto_setup=true'
```

This format allows to define multiple hosts for a Redis Cluster and still contains valid URLs. Custom configuration is still supported, it can be specified on only one of the URLs in the DSN (see `lazy` above). If the user provides multiple configurations on different URLs, they are simply merged with the following code and if an option is defined multiple times then the latest takes precedence (see `multipleConfig` above).

I understand the way the DSN is handled could not suit you. Please, if you close this PR only for the DSN part, just tell me and I will make a new PR with only the first commit.

Commits
-------

04530fb [Messenger] Support Redis Cluster
symfony-splitter pushed a commit to symfony/redis-messenger that referenced this pull request Apr 13, 2021
This PR was squashed before being merged into the 5.3-dev branch.

Discussion
----------

[Messenger] Support Redis Cluster

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #38264
| License       | MIT
| Doc PR        | symfony/symfony-docs#14956

This PR brings support for Redis Cluster in the Messenger component:

- The first commit _Support RedisCluster instance_ allows to pass a `RedisCluster` object when instanciating the `Connection` class, which brings support for Redis Cluster without any friction.
- The second commit _Support multiple hosts DSN for Redis Cluster_ is more opiniated and brings a DSN format to configure a Redis Cluster from `config/packages/messenger.yaml`.

Instanciating `Connection` with a `RedisCluster` object:

```php
$redis = new \RedisCluster(null, ['host-01:6379', 'host-02:6379', 'host-03:6379', 'host-04:6379']);
$connection = new Connection([], [], [], $redis);
```

Configuring a Redis Cluster from YAML:

```yaml
// config/packages/messenger.yaml

framework:
    messenger:
            metadata:
                default: 'redis://host-01:6379,redis://host-02:6379,redis://host-03:6379'
                lazy: 'redis://host-01:6379?lazy=1,redis://host-02:6379,redis://host-03:6379'

                # Configuration will be `lazy = true` and `auto_setup = true`
                multipleConfig: 'redis://host-01:6379?lazy=1&auto_setup=false,redis://host-02:6379,redis://host-03:6379?auto_setup=true'
```

This format allows to define multiple hosts for a Redis Cluster and still contains valid URLs. Custom configuration is still supported, it can be specified on only one of the URLs in the DSN (see `lazy` above). If the user provides multiple configurations on different URLs, they are simply merged with the following code and if an option is defined multiple times then the latest takes precedence (see `multipleConfig` above).

I understand the way the DSN is handled could not suit you. Please, if you close this PR only for the DSN part, just tell me and I will make a new PR with only the first commit.

Commits
-------

04530fb2d7 [Messenger] Support Redis Cluster
@xabbuh xabbuh removed the Waiting Code Merge Docs for features pending to be merged label May 7, 2021
@xabbuh xabbuh modified the milestones: next, 5.3 May 7, 2021
@xabbuh
Copy link
Member

xabbuh commented May 7, 2021

Thank you @nesk.

@xabbuh xabbuh merged commit 3856194 into symfony:5.x May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants