phoenixframework / phoenix_pubsub_redis

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

Make Redis channel configurable #66

Open jstr opened 1 year ago

jstr commented 1 year ago

Here I'm proposing an addition to the configuration options for Phoenix.PubSub.Redis to make it possible to specify the Redis channel for pubsub directly.

Motivation

Currently the Redis channel name is derived from the adapter name, e.g. "phx:Elixir.MyApp.PubSub.Adapter". This is not entirely obvious and could pose a challenge for some applications:

Personally I ran into this with an umbrella app where we want to have separate pubsub processes per app to avoid coupling.

Changes

Changes are straight forward, basically just accepting an optional redis_channel configuration argument and stashing that in ETS. The implementation defaults to the current channel naming where no channel name is specified, so as to be backward compatible.