matryer / vice

Go channels at horizontal scale (powered by message queues)
https://medium.com/@matryer/introducing-vice-go-channels-across-many-machines-bcac1147d7e2
Apache License 2.0
1.54k stars 79 forks source link

added support for nats streaming #32

Closed HeavyHorst closed 7 years ago

HeavyHorst commented 7 years ago

I've added support for nats-streaming to the nats queue implementation. https://nats.io/documentation/streaming/nats-streaming-intro/

a new nats-streaming transport can easily be created with: New(WithStreaming("clusterID", "clientID"))

  1 package main
  2
  3 import (
  4         "fmt"
  5
  6         vn "github.com/matryer/vice/queues/nats"
  7 )
  8
  9 func main() {
 10         nt := vn.New(vn.WithStreaming("test-cluster", "test-id"))
 11         defer nt.Stop()
 12
 13         rc := nt.Receive("test123")
 14
 15         for {
 16                 select {
 17                 case v := <-rc:
 18                         fmt.Println(string(v))
 19                 case err := <-nt.ErrChan():
 20                         panic(err)
 21                 }
 22         }
 23 }

@matryer @piotrrojek what do you think?

matryer commented 7 years ago

Awesome.