subscriber

package
v0.0.0-...-92da4da Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageHandler

type MessageHandler func(msg *message.Message) (exit bool)

MessageHandler takes a message from Producer when the returned value `exit` is true, the producer needs to stop producing and exit current loop

type Producer

type Producer interface {
	// Start is a non-blocking call. It starts internal goroutine/s that produce messages.
	Start() error
	// Shutdown stops the producer and cleans up its resources. Should wait for all internal goroutines to exit.
	Shutdown()
}

type ProducerFactory

type ProducerFactory func(handler MessageHandler, topic string) Producer

ProducerFactory creates Producer instances for the desired topic the handler func is stored in the Producer, to be called when a message is produced

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

func NewSubscriber

func NewSubscriber(producerFactory ProducerFactory) *Subscriber

func (*Subscriber) Close

func (s *Subscriber) Close() error

func (*Subscriber) Subscribe

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

Jump to

Keyboard shortcuts

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