Recently I was setting up phoenix_pubsub_redis in our application, and I incurred in a few problems connecting to ElastiCache redis. The most confusing thing was that I was able to connect to redis using Redix.start_link normally, but if I used the same opts with phoenix_pubsub_redis it would fail. In the end the problem was that the option usernameis been ignored.
Looking in the repository we have a few other open and closed PRs with similar issues.
Updating the code just to add behaviour on the parsing of redis urls or allowing new options that redix supports.
I would like to propose delegating the handle of redis connection opts directly to redis,
so we don't have to maintain a version of the url parsing inside of phoenix_pubsub_redis
remember to always have a updated version of the opts supported by redix inside the codebase
We could do that by introducing a new option called redis_opts and then pass that option directly to redix, and soft-deprecate the old option (host, password etc).
In order to keep backward compatibility we could continue supporting the existing options, but encourage the use of the new redis_opts.
In addition to that we can start using the url parsing directly from redix. Currently the function Redix.URI.opts_from_uri/1 is private. I plan to open a discussion on redix on the best way to pass this url to redix, so maybe we can remove this responsibility completely from the codebase.
Motivation
Recently I was setting up
phoenix_pubsub_redis
in our application, and I incurred in a few problems connecting to ElastiCache redis. The most confusing thing was that I was able to connect to redis usingRedix.start_link
normally, but if I used the same opts withphoenix_pubsub_redis
it would fail. In the end the problem was that the optionusername
is been ignored.Looking in the repository we have a few other open and closed PRs with similar issues. Updating the code just to add behaviour on the parsing of redis urls or allowing new options that
redix
supports.Proposed Solution
I would like to propose delegating the handle of redis connection opts directly to redis,
phoenix_pubsub_redis
We could do that by introducing a new option called
redis_opts
and then pass that option directly to redix, and soft-deprecate the old option (host, password etc). In order to keep backward compatibility we could continue supporting the existing options, but encourage the use of the newredis_opts
.In addition to that we can start using the url parsing directly from
redix
. Currently the functionRedix.URI.opts_from_uri/1
is private. I plan to open a discussion onredix
on the best way to pass thisurl
toredix
, so maybe we can remove this responsibility completely from the codebase.Does the approach makes sense?