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

Can't config with Heroku REDIS_URL #290

Open
AugustoPedraza opened this issue Oct 16, 2017 · 5 comments
Open

Can't config with Heroku REDIS_URL #290

AugustoPedraza opened this issue Oct 16, 2017 · 5 comments

Comments

@AugustoPedraza
Copy link

How should I use the following Redis URL to connect?

redis://h:77cp773ab5102292b1632dd060f3ae366ce745c845cfc473fd7d9a4b10662caaf@ec2-35-224-34-235.cxfgte-1.amaaggrnaws.com:32959

@egeersoz
Copy link

I have the same question. I need to use Exq with an externally hosted Redis service, so I need to be able to provide it with a redis:// URI, as well as an API username and key.

See here for an example: https://openredis.com/docs/api

@akira
Copy link
Owner

akira commented Nov 19, 2017

I think there are two different situations here.

The first situation @AugustoPedraza - you should be able to specify a :url property with this and have that work. That should work, but even if that URL doesn't parse correctly, you should still be able to break it up into the parts and specify them separately.

The second situation @egeersoz is basically a dynamic URL that is returned via a curl request. With the current code base, one option is to write a start wrapper bash script that curls that endpoint and then sets the environment variable for REDIS connection info based on the returned data. You can then use environment variable option in the config to read those. The codebase can probably be modified to make this easier to specify dynamic configs (similar to Phoenix), but I don't have time to implement this (but would look at a PR).

@daneb
Copy link

daneb commented Mar 6, 2018

@AugustoPedraza I setup something like this:

config :exq,
  name: Exq,
  host: URI.parse(System.get_env("REDISCLOUD_URL")).host,
  password: List.last(String.split(URI.parse(System.get_env("REDISCLOUD_URL")).query, ":"))
  port: URI.parse(System.get_env("REDISCLOUD_URL")).port,
  namespace: "exq",
  concurrency: 500,
  queues: ["mail"],
  scheduler_enable: true

Of course even easier would be to break up the URI into their own individual Heroku ENV variables.

@jumichot
Copy link

jumichot commented Jan 2, 2019

For the ones on heroku's redis the solution of @daneb is the one I ended up with. Sometimes Heroku change the REDIS_URL, so if you break up the URI into individual env vars you will have some problems...

uri = URI.parse(System.get_env("REDIS_URL"))

config :exq,
  name: Exq,
  host: uri.host || "127.0.0.1",
  password: List.last(String.split(uri.userinfo, ":")) || "",
  port: uri.port || 6379,

@hebbo
Copy link

hebbo commented Sep 30, 2022

With Redix 1.2.0 there is a function available to parse the Heroku connection string:
https://hexdocs.pm/redix/1.2.0/Redix.URI.html#to_start_options/1

Screenshot 2022-09-30 at 15 46 22

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

No branches or pull requests

6 participants