Sidekiq: Validate REDIS_PROVIDER

Created on 17 Sep 2018  Â·  8Comments  Â·  Source: mperham/sidekiq

REDIS_PROVIDER is meant to hold the name of the env var that contains the Redis URL. I see people misunderstand this abstraction and place the URL directly in REDIS_PROVIDER frequently. Add validation that will fail fast if the user makes this mistake. This is a breaking change and needs to be called out in the changelog loudly.

REDIS_PROVIDER should be set to the name of the variable which contains the Redis URL, not a URL itself.
Platforms like Heroku will sell addons that publish a *_URL variable.  You need to tell Sidekiq with REDIS_PROVIDER, e.g.:

REDIS_PROVIDER=REDISTOGO_URL
REDISTOGO_URL=redis://somehost.example.com:6379/4

Most helpful comment

Assume you are using Redis-To-Go. Heroku will only allow RTG to modify the ENV var called REDISTOGO_URL in your app. So if RTG wants to migrate you seamlessly to another datacenter, your app uses their variable directly and they modify the value so that on reboot, your app picks up the new Redis instance. REDIS_URL is not a thing they can control. Sidekiq supports it for those people who want to run and manage their own Redis instance.

Since there are many Redis service providers, you use REDIS_PROVIDER to tell Sidekiq which ENV var is the live Redis and Sidekiq will use that variable to find Redis.

All 8 comments

Maybe we should namespace the variable too and deprecate REDIS_PROVIDER ?SIDEKIQ_REDIS_PROVIDER ? wdyt ?
I can work on it in another PR .

@mperham I can't understand why Sidekiq provides indirect Redis server reference? What's wrong with directENV['REDIS_URL'] setting at Heroku?

How would you use a 3rd party Redis add-on, like Redis-to-Go?

On Dec 9, 2018, at 06:37, Andrew Babichev notifications@github.com wrote:

Sorry, why Sidekiq provides indirect Redis server reference? What's wrong with directREDIS_URL setting at Heroku?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

I have never deployed sidekiq to Heroku, does Redis-to-Go addon requires specific URL env var name?

All Redis providers require a custom *_URL variable. That’s how Heroku addons work.

On Dec 9, 2018, at 12:47, Andrew Babichev notifications@github.com wrote:

I have never deployed sidekiq to Heroku, does Redis-to-Go requires specific URL env var name?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Yeah, I see. I doubt people deploy multiple Redis add-ons and it's sensible for me to have a common env var name for all of them (convention over configuration) – REDIS_URL. Thanks for the clarification 🙇

Assume you are using Redis-To-Go. Heroku will only allow RTG to modify the ENV var called REDISTOGO_URL in your app. So if RTG wants to migrate you seamlessly to another datacenter, your app uses their variable directly and they modify the value so that on reboot, your app picks up the new Redis instance. REDIS_URL is not a thing they can control. Sidekiq supports it for those people who want to run and manage their own Redis instance.

Since there are many Redis service providers, you use REDIS_PROVIDER to tell Sidekiq which ENV var is the live Redis and Sidekiq will use that variable to find Redis.

Got it, thank you 🙇

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidcelis picture davidcelis  Â·  3Comments

BeRMaNyA picture BeRMaNyA  Â·  3Comments

michaeldiscala picture michaeldiscala  Â·  4Comments

HenleyChiu picture HenleyChiu  Â·  4Comments

agrobbin picture agrobbin  Â·  4Comments