phoenixframework / phoenix_pubsub_redis

The Redis PubSub adapter for the Phoenix framework
175 stars 66 forks source link

Delegate redis connection build to redix #61

Open thiamsantos opened 1 year ago

thiamsantos commented 1 year ago

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 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 username 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,

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.

Does the approach makes sense?