eventbus

package
v1.0.0-beta.159 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextPublisher

type ContextPublisher interface {
	// PublishIfNoError publishes an event if the error is nil or returns the error
	PublishIfNoError(event marshaler.Event, err error) error
}

type Options

type Options struct {
	Publisher              message.Publisher
	Config                 config.EventsConfiguration
	Logger                 *slog.Logger
	MarshalerTransformFunc marshaler.TransformFunc
}

type Publisher

type Publisher interface {
	// Publish publishes an event to the event bus
	Publish(ctx context.Context, event marshaler.Event) error

	// WithContext is a convinience method to publish from the router. Usually if we need
	// to publish from the router, a function returns a marshaler.Event and an error. Using this
	// method we can inline the publish call and avoid the need to check for errors:
	//
	//    return p.WithContext(ctx).PublishIfNoError(worker.handleEvent(ctx, event))
	WithContext(ctx context.Context) ContextPublisher

	Marshaler() marshaler.Marshaler
}

func New

func New(opts Options) (Publisher, error)

func NewMock

func NewMock(t *testing.T) Publisher

Jump to

Keyboard shortcuts

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