adonisjs / transmit

A Server-Sent-Event module for AdonisJS
MIT License
65 stars 4 forks source link

Add channel name scoping for different environments #21

Open sivo1981 opened 4 months ago

sivo1981 commented 4 months ago

Package version

@adonisjs/transmit@1.0.0

Describe the bug

Is it possible to include some kind of channel name scoping when using Redis as transport provider. When using same Redis instance all environments receive event from Pub/sub.

Reproduction repo

No response

RomainLanz commented 4 months ago

Hey @sivo1981?

Could you please elaborate on what you mean by "channel name scoping"?

sivo1981 commented 4 months ago

Application with same code base is runing in two different environments "production" and "test". Using channel name lets say "users" and transmit transport Redis with connection to the same server instance it will result in sending events on both environments because redis pub/sub doesn't care about this, it just sends event to all clients subscribed to this channel.

This is also stated here: https://redis.io/docs/latest/develop/interact/pubsub/

Probably it would be the best options to prefix channel names based on some env variable so the final channel name would be ${CHANNEL_PREFIX}_users. This is already implemented for @adonisjs/redis package via REDIS_PREFIX for example.