slact / nchan

Fast, horizontally scalable, multiprocess pub/sub queuing server and proxy for HTTP, long-polling, Websockets and EventSource (SSE), powered by Nginx.
https://nchan.io/
Other
3.01k stars 293 forks source link

Publish to channel from Redis SUBSCRIBE #249

Open MrDefacto opened 8 years ago

MrDefacto commented 8 years ago

Hi,

Are there any plan do add functionality that will map/bridge nchan publisher do redis subscribe. For example command: nchan_publisher_redis_subscribe 'redis_channel' will subscribe to redis (SUBSCRIBE feature) and publish to nchan subscribers all brodcasts from redis?

Best regards,

slact commented 8 years ago

Can you give me a use case for this? There is already nchan_publisher_upstream_request which can be used to pass a published message to an upstream app via HTTP. I think adding an option to publish on a custom PUBSUB channel would just get confusing...

MrDefacto commented 8 years ago

for example publisher will subscribe to redis: SUBSCRIBE 'keyevent@0:lpush' 'variable'

and then any lpush to variable in redis will publish it to subscribers.

sending command to redis via it's protocol not via http.

slact commented 8 years ago

Oh, I understand. That could be a useful feature, but I'm not sure it's possible in the context of nginx configuration. If you have any ideas on how this feature could be configured, I'd like to hear them.

MrDefacto commented 8 years ago

in publisher location definition something like:

location ~ /publish/$ {
nchan_publisher;
nchan_redis_pass redis_cluster;
nchan_redis_publisher_subscribe 'redis_channel' 'redis_channel2'
nchan_channel_id "test";
}

Sample: nchan_redis_publisher_subscribe 'keyevent@0:lpush'

Just like Redis SUBSCRIBE command works.

Redis is then returning for subscribers (in this case nchan) something like this:

1) "message"
2) "__keyevent@0__:lpush"
3) "{channel:/test}:messages"

Parsing this can be even made in JS but it can by also preparsed by nchan.

sublime392 commented 7 years ago

I would like this because Laravel 5.3 broadcaster has a Redis driver but not an nchan driver.