rabbitmq

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

eh-rabbitmq

rabbitmq event bus implementation for eventhorizon

Documentation

Index

Constants

View Source
const DefaultNumRetries = 0

DefaultNumRetries is the retry value to use if not set in the context.

View Source
const (
	// InfiniteRetries is the value to retry without discarding an event.
	InfiniteRetries = math.MaxInt64
)

Variables

View Source
var ErrDiscardEvent = errors.New("drop event from eventbus")

ErrDiscardEvent is used to drop an event manually.

Functions

func NewContextWithNumRetries added in v0.4.1

func NewContextWithNumRetries(ctx context.Context, numRetries int64) context.Context

NewContextWithNumRetries sets the retries value to use in the context. The number of retries is used to determine how often an event has failed to be handled.

func NumRetriesFromContext added in v0.4.1

func NumRetriesFromContext(ctx context.Context) int64

NumRetriesFromContext returns the number of retries from the context, or zero.

Types

type EventBus

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

EventBus is a local event bus that delegates handling of published events to all matching registered handlers, in order of registration.

func NewEventBus

func NewEventBus(addr, appID, clientID, exchange, topic string, options ...Option) (*EventBus, error)

NewEventBus creates an EventBus, with optional settings.

func (*EventBus) AddHandler

func (b *EventBus) AddHandler(ctx context.Context, m eh.EventMatcher, h eh.EventHandler) error

AddHandler implements the AddHandler method of the eventhorizon.EventBus interface.

func (*EventBus) Close

func (b *EventBus) Close() error

Close implements the Close method of the eventhorizon.EventBus interface.

func (*EventBus) Errors

func (b *EventBus) Errors() <-chan error

Errors implements the Errors method of the eventhorizon.EventBus interface.

func (*EventBus) HandleEvent

func (b *EventBus) HandleEvent(ctx context.Context, event eh.Event) error

HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface.

func (*EventBus) HandlerType

func (b *EventBus) HandlerType() eh.EventHandlerType

HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.

type Option

type Option func(*EventBus) error

Option is an option setter used to configure creation.

func WithCodec

func WithCodec(codec eh.EventCodec) Option

WithCodec uses the specified codec for encoding events.

func WithRetry added in v0.4.0

func WithRetry(maxRetries int64, delays []time.Duration) Option

WithRetry enables event retries. If maxRetries is bigger than the number of delays provided, it will use the last value until maxRetries has been reached. Use InfiniteRetries to never drop the message.

Jump to

Keyboard shortcuts

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