gochannel

package
v0.4.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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) Close added in v0.2.0

func (g *GoChannel) Close() error

func (*GoChannel) Publish added in v0.2.0

func (g *GoChannel) Publish(topic string, messages ...*message.Message) error

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) Publisher added in v0.3.0

func (g *GoChannel) Publisher() message.Publisher

func (*GoChannel) Subscribe added in v0.2.0

func (g *GoChannel) Subscribe(ctx context.Context, topic string) (<-chan *message.Message, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL