-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redis backed AsyncPubSub #42
Comments
It's very much possible. Pioneer can take any app.redis.subscribe(
to: "channel_1", "channel_2",
messageReceiver: { channel, message in
switch channel {
case "channel_1": // do something with the message
default: break
}
},
onUnsubscribe: { channel, subscriptionCount in
print("unsubscribed from \(channel)")
print("subscriptions remaining: \(subscriptionCount)")
}) which is easy to translate to AsyncStream { con in
app.redis.subscribe(
to: ...,
messageReceiver: { _, message in
con.yield(message)
},
onUnsubscribe: { _, _ in
con.finish()
})
...
} I think implementing something from that which have similar API to The only problem is that I don't think it belong here. It make more sense as a separate package.
|
I might try to make a separate package for this and maybe make |
I agree. I think this approach makes a lot of sense. |
I have a working solutions for the public protocol from The changes are not final yet, I might change my mind on it to make it simpler. Would appreciate your thoughts on it. |
I think the |
It might make sense to consider adding something analogous to the following:
https://www.apollographql.com/blog/backend/subscriptions/graphql-subscriptions-with-redis-pub-sub/
While
AsyncPubSub
is great for many use cases, in production where we might have multiple server instances, it may be necessary to use something like Redis instead of an in memory pubsub to handle subscriptions. It would be cool if there could be an option to use Redis when configuring Pioneer and it would be even cooler if we could use the same API as AsyncPubSub.So it would be a simple configuration change for the developer, and then we could switch between redis and the in memory AsyncPubSub without changing our EventStream code.
Do you think this is possible? I know this might be a challenge.
The text was updated successfully, but these errors were encountered: