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

Allow setting URL for redis config #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

germsvel
Copy link
Collaborator

What changed?

We allow setting a Redis URL in our config via redis_options instead of having to specify a host, port, and password.

E.g.

// instead of this
config :redbird, :redis_options, [host: ...]

// we can now do this
config :redbird, :redis_options, [url: "redis:// ..."]

This is particularly helpful when dealing with Redis + SSL, when the URL scheme changes from redis to rediss.

Implementation details

Redix (the library we use to communicate with Redis) will automatically set ssl: true when it is passed a URL with a rediss scheme.

Unfortunately, the only way to pass a URL to Redix is by passing a modified set of options ({url, list_of_opts} instead of list_of_opts).

Instead of passing those options to Redbird.Redis.start_link/1 only to then pass them again to Redix.start_link/1, we now rely on Redix's child_spec function directly, and put it in our supervision tree.

Finally, to abstract the configuration of options, we create a new module Redbird.Config which handles the merging of options and separating the url from the rest of the options if one is present.

What changed?
=============

We allow setting a Redis URL in our config via `redis_options` instead
of having to specify a host, port, and password.

E.g.

```
// instead of this
config :redbird, :redis_options, [host: ...]

// we can now do this
config :redbird, :redis_options, [url: "redis:// ..."]
```

This is particularly helpful when dealing with Redis + SSL, when the URL
scheme changes from `redis` to `rediss`.

Implementation details
----------------------

`Redix` (the library we use to communicate with Redis) will
automatically set `ssl: true` when it is passed a URL with a `rediss`
scheme.

Unfortunately, the only way to pass a URL to `Redix` is by passing a
modified set of options (`{url, list_of_opts}` instead of
`list_of_opts`).

Instead of passing those options to `Redbird.Redis.start_link/1` only to
then pass them again to `Redix.start_link/1`, we now rely on `Redix`'s
`child_spec` function directly, and put it in our supervision tree.

Finally, to abstract the configuration of options, we create a new
module `Redbird.Config` which handles the merging of options and
separating the `url` from the rest of the options if one is present.
@JacquiManzi
Copy link

I'd love to use this project and this is the only blocker for me at the moment.

@relip
Copy link

relip commented Feb 9, 2022

Seems like this PR got approved quite while ago but still not merged into master? As @JacquiManzi mentioned this is the only blocker for us to upgrade redbird to the latest version and we hope to see this to be merged soon.

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.

4 participants