centrifugal / centrifuge

Real-time messaging library for Go. The simplest way to add feature-rich and scalable WebSocket support to your application. The core of Centrifugo server.
https://pkg.go.dev/github.com/centrifugal/centrifuge
MIT License
1.06k stars 92 forks source link

Publish message directly to Redis #408

Open voodoo-dn opened 2 weeks ago

voodoo-dn commented 2 weeks ago

Hi!

I develop messenger app and think about following integration:

Kafka topic contains messages, Kafka consumer receives message and publishes to Redis, Centrifugo nodes get messages from Redis and deliver to the client.

As I understood, such function is not available out of the box?

Thanks!

FZambia commented 2 weeks ago

Hello @voodoo-dn

Yes, there is no such functionality, the communication layer between Centrifuge and Redis is an internal implementation detail. Technically it's possible to publish in Redis channels in the format Centrifuge node expects, but the message format may change on that level and Centrifuge features like history cache won't be available.

Kafka topic contains messages, Kafka consumer receives message and publishes to Redis, Centrifugo nodes get messages from Redis and deliver to the client.

I suggest changing this to: Kafka topic contains messages, Kafka consumer receives message and publishes to Centrifuge using Node.Publish (probably implement HTTP endpoint for this), Centrifuge nodes get messages from Redis and deliver to the client.

P.S. I am answering on question assuming you are using THIS library for your app, not https://github.com/centrifugal/centrifugo server. If you are using Centrifugo - then publish HTTP API is already there.