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)
typePublisherinterface {
Marshaller(marshallerMarshaller)
Publish(context.Context, string, interface{}) errorErrors() <-chanerror
}
typeSubscriberinterface {
UnMarshaller(unmarshallerUnMarshaller)
Start() <-chanMessageErrors() <-chanerrorStop() error
}
typeMessageinterface {
UnMarshal(interface{}) errorDone() error
}- Sergey Chebotar - design / rabbitmq implementation
- Stan Shulga - examples for rabbitmq