In-Memory message broker over HTTP API using a concurrent, thread-safe pubsub architecture.
> go get -v github.com/Manan007224/pbq
> cd $GOPATH/src/github.com/Manan007224/pbq
> go build -o pbq
> ./pbq
Pbq by default runs on localhost:3000
Run server on localhost:3000
./pqb
Subscribe
./pbq --client --topic=foo --subscribe
Publish
echo "A completely arbitrary message" | ./pbq --client --topic=foo --publish
Subscriber
c := client.New()
tick := time.NewTicker(time.Second)
for _ = range tick.C {
if err := c.Publish("foo", []byte(`bar`)); err != nil {
log.Println(err)
break
}
}
Publisher
c := client.New()
ch, err := c.Subscribe("foo")
if err != nil {
log.Println(err)
return
}
defer c.Unsubscribe(ch)
for {
select {
case e := <-ch:
log.Println(string(e))
fmt.Println(string(e))
}
}
Manan Maniyar: E-mail, @Manan007224