Documentation ¶
Index ¶
- func NewGoChannel(config Config, logger watermill.LoggerAdapter) message.PubSub
- type Config
- type GoChannel
- func (g *GoChannel) Close() error
- func (g *GoChannel) Publish(topic string, messages ...*message.Message) error
- func (g *GoChannel) Publisher() message.Publisher
- func (g *GoChannel) Subscribe(ctx context.Context, topic string) (<-chan *message.Message, error)
- func (g *GoChannel) Subscriber() message.Subscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGoChannel ¶
func NewGoChannel(config Config, logger watermill.LoggerAdapter) message.PubSub
NewGoChannel creates new GoChannel Pub/Sub.
This GoChannel is not persistent. That means if you send a message to a topic to which no subscriber is subscribed, that message will be discarded.
Types ¶
type Config ¶ added in v0.3.0
type Config struct { // Output channel buffer size. OutputChannelBuffer int64 // If persistent is set to true, when subscriber subscribes to the topic, // it will receive all previously produced messages. // // All messages are persisted to the memory (simple slice), // so be aware that with large amount of messages you can go out of the memory. Persistent bool // When true, Publish will block until subscriber Ack's the message. // If there are no subscribers, Publish will not block (also when Persistent is true). BlockPublishUntilSubscriberAck bool }
type GoChannel ¶ added in v0.2.0
type GoChannel struct {
// contains filtered or unexported fields
}
GoChannel is the simplest Pub/Sub implementation. It is based on Golang's channels which are sent within the process.
GoChannel has no global state, that means that you need to use the same instance for Publishing and Subscribing!
When GoChannel is persistent, messages order is not guaranteed.
func (*GoChannel) Publish ¶ added in v0.2.0
Publish in GoChannel is NOT blocking until all consumers consume. Messages will be send in background.
Messages may be persisted or not, depending of persistent attribute.
func (*GoChannel) Subscribe ¶ added in v0.2.0
Subscribe returns channel to which all published messages are sent. Messages are not persisted. If there are no subscribers and message is produced it will be gone.
There are no consumer groups support etc. Every consumer will receive every produced message.
func (*GoChannel) Subscriber ¶ added in v0.3.0
func (g *GoChannel) Subscriber() message.Subscriber