Comments (5)
I might try to make a separate package for this and maybe make
AsyncPubSubBase
protocol so that you can build something that will have similar API toAsyncPubSub
, but I can't make any guarantees for that.
I have a working solutions for the public protocol from AsyncPubSub
so that you can build a custom pubsub implementation with similar API to AsyncPubSub
. More details on the changes is on #45
The changes are not final yet, I might change my mind on it to make it simpler. Would appreciate your thoughts on it.
from pioneer.
It's very much possible. Pioneer can take any EventStream
created from any AsyncSequence
. Looking at this page of the Vapor docs, subscribing to a channel looked like
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
.
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 AsyncPubSub
should be relatively straightforward. All you need to is to make a struct, wrap that code above into a method for the struct named asyncStream
, and wrap the RediStack
publish
method into a method as well named publish
.
The only problem is that I don't think it belong here. It make more sense as a separate package.
AsyncPubSub
is provided in this library because I wanted to provide at least a basic in memory solution for Pub/Sub that can be used to start with immediately without extra setup.
from pioneer.
I might try to make a separate package for this and maybe make AsyncPubSubBase
protocol so that you can build something that will have similar API to AsyncPubSub
, but I can't make any guarantees for that.
from pioneer.
I agree. I think this approach makes a lot of sense.
from pioneer.
I think the PubSub
protocol should be available in v0.8.0
. Theres should also be part of documentation that explains a bit more about creating a custom PubSub
implementation.
from pioneer.
Related Issues (20)
- Public structs have no public initialisers
- After pausing the websocket connection from Apollo iOS, it can't reconnect. HOT 12
- Documentation search is pointing to incorrect path HOT 2
- Better typing for payload HOT 1
- Improvement to Test HOT 1
- Improvement to optional spec-compliant HOT 4
- Field Resolve Middleware HOT 1
- VaporMiddleware responding incorrectly to all paths HOT 7
- Plugins
- Error: 'ConcurrentResolve' is only available in macOS 12 or newer HOT 4
- TestConsumer Improvement
- subscription Precondition failed HOT 13
- Subscription via gateway HOT 3
- Improvement to spec-compliant HOT 1
- Value null in data on errors HOT 8
- GraphQL together with gRPC HOT 4
- Support for the new Swift Universal HTTP types
- Custom Directives HOT 2
- Contributing Guide
- `websocketOnInit` has not been implemented
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pioneer.