Pubsub
Simple PubSub interface for golang apps with plugable drivers
Install / Use
/learn @gocontrib/PubsubREADME
pubsub
Simple PubSub interface for golang apps with plugable drivers.
Supported drivers
- in-memory implementation based on go channels
- nats.io
- redis using redigo
- nsq.io - draft, not completed!
API
API is pretty simple
// Hub interface of pubsub system.
type Hub interface {
// Publish sends input message to specified channels.
Publish(channels []string, msg interface{})
// Subscribe opens channel to listen specified channels.
Subscribe(channels []string) (Channel, error)
// Close stops the pubsub hub.
Close() error
}
// Channel to listen pubsub events.
type Channel interface {
// Read returns channel to receive events.
Read() <-chan interface{}
// Close stops listening underlying pubsub channels.
Close() error
// CloseNotify returns channel to receive event when this channel is closed.
CloseNotify() <-chan bool
}
Server-sent events
See code of built-in package
TODO
- [x] continuous integration
- [ ] (in progress) unit tests
- [ ] example for websocket event streams
- [x] remove dependency on "github.com/drone/config" module
- [ ] get working nsq driver
- [ ] find and implement more drivers maybe faster then nats.io
- [ ] sarama client for Apache Kafka
- [ ] zmq4 client for zeromq
