events

package
v0.4.18 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventRouter

type EventRouter struct {
	Publisher  message.Publisher
	Subscriber message.Subscriber
	// contains filtered or unexported fields
}

func NewEventRouter

func NewEventRouter(options ...EventRouterOption) (*EventRouter, error)

func (*EventRouter) AddHandler

func (e *EventRouter) AddHandler(name string, topic string, f func(msg *message.Message) error)

func (*EventRouter) Close

func (e *EventRouter) Close() error

func (*EventRouter) DumpRawEvents

func (e *EventRouter) DumpRawEvents(msg *message.Message) error

func (*EventRouter) Run

func (e *EventRouter) Run(ctx context.Context) error

func (*EventRouter) RunHandlers

func (e *EventRouter) RunHandlers(ctx context.Context) error

type EventRouterOption

type EventRouterOption func(*EventRouter)

func WithLogger

func WithLogger(logger watermill.LoggerAdapter) EventRouterOption

func WithPublisher

func WithPublisher(publisher message.Publisher) EventRouterOption

func WithSubscriber

func WithSubscriber(subscriber message.Subscriber) EventRouterOption

func WithVerbose

func WithVerbose(verbose bool) EventRouterOption

type PublisherManager

type PublisherManager struct {
	Publishers map[string][]message.Publisher
	// contains filtered or unexported fields
}

PublisherManager is used to distribute messages to a set of Publishers. As such, you "subscribe" a publisher to the given topic. When you Publish a message, it will get distributed to all publishers on the channel they were subscribed with.

The Manager also keeps a sequence number for each outgoing message, in the order they are handled by Publish.

func NewPublisherManager

func NewPublisherManager() *PublisherManager

func (*PublisherManager) Publish

func (s *PublisherManager) Publish(payload interface{}) error

Publish distributes a message to all Publishers across all topics. Serializing the payload to JSON is done by Publish itself.

Returns an error for any processing or distribution issues.

func (*PublisherManager) PublishBlind

func (s *PublisherManager) PublishBlind(payload interface{})

func (*PublisherManager) SubscribePublisher

func (s *PublisherManager) SubscribePublisher(topic string, sub message.Publisher)

Jump to

Keyboard shortcuts

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