Pub/Sub interface and implementations for
- Dummy: dummy implementation without message transmission
- Mem: exchange in app memory
- RabbitMQ
Todo implementations
- Kafka
- ZMQ
Published - publish the messages Subscriber - listen for messages Message - interface that wraps messages that receives the Subscriber
Interfaces provide methods to register functions for Marshaling and UnMarshaling.
- Create new Published and attach Marshaller to it
- Publish you variable foo with Publisher.Publish(foo). Marshalling happens in Publisher.Publish method
- Create new Subscriber
- Attach unmarshaller
- Listen for incoming messages on channel from Subscriber.Start
- Each message could be unmarshalled by calling message.UnMarshal(&structure)
type Publisher interface {
Marshaller(marshaller Marshaller)
Publish(context.Context, string, interface{}) error
Errors() <-chan error
}
type Subscriber interface {
UnMarshaller(unmarshaller UnMarshaller)
Start() <-chan Message
Errors() <-chan error
Stop() error
}
type Message interface {
UnMarshal(interface{}) error
Done() error
}
- Sergey Chebotar - design / rabbitmq implementation
- Stan Shulga - examples for rabbitmq