Comments (7)
I made a suggestion in #10 that you actually treat every call to Receive
as a subscription. As it is trivial in Go to then take the channel and use it as a work queue by sharing that channel. Where as, if you treated Receive as work-queue like, then every consumer would get the same channel and wouldn't be able to choose to have subscription semantics. Well... without then copying each message and fanning out themselves.
from vice.
At the moment every call to Receive("something") would get the same channel in every implementation.
So if we are using just a single transport on a single node we have already work queue semantics.
But if we create more than one transport or let our program run on more than one node we get sometimes pub/sub and sometimes work queue behaviour.
Receiver.go
package main
import (
"fmt"
vn "github.com/matryer/vice/queues/redis"
)
func main() {
nt := vn.New()
defer nt.Stop()
rc := nt.Receive("test123")
for i := 0; i < 5; i++ {
v := <-rc
fmt.Println(string(v))
}
}
Sender.go
package main
import (
"fmt"
"time"
vn "github.com/matryer/vice/queues/redis"
)
func main() {
nt := vn.New()
defer nt.Stop()
sc := nt.Send("test123")
for i := 0; i < 5; i++ {
sc <- []byte(fmt.Sprintf("%d Hallo", i))
time.Sleep(1 * time.Second)
}
}
Redis:
NSQ:
from vice.
I suppose vice is intended to be a queue and not pub sub. So queue semantics by default makes sense over subscription.
from vice.
I agree
from vice.
Right, Vice is a queue. It's tough to think of a way to properly test that stuff; so I think we just have to be careful about it in the implementations.
Do we need to tweak anything here?
from vice.
The nats implementation just needs to use QueueSubscribe instead of Subscribe.
I'm sure redis can also be used as a work queue.
from vice.
from vice.
Related Issues (20)
- cannot compile example greeter service main.go HOT 2
- some messages might get dropped due to buffered channels HOT 3
- Async Behaviour varies between nsq and Nats HOT 7
- Setup Travis HOT 1
- nsq: empty buffer on Stop HOT 1
- redis: empty buffer on Stop
- sqs: data race
- sqs: empty buffer on Stop
- Some code deficiencies
- Using io.Reader for Transport interface instead of []byte HOT 2
- ipfs pubsub as a queue type HOT 4
- RabbitMQ transport: reconnect HOT 2
- Project Status HOT 3
- Redis queue imports fail - gopkg.in is not supported any longer HOT 1
- Question about processing file between multiple nodes
- Cannot control message pulling from the queue
- context.Context friendly API
- Doesn't build with nats HOT 1
- Is this project still being maintained?
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 vice.