event

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxEvents is the default maximum number of events to store
	DefaultMaxEvents = 1000
)

Variables

View Source
var ErrInvalidEvent = errors.New("invalid event")

ErrInvalidEvent is returned when an invalid event is published

Functions

func NewMemoryPublisher

func NewMemoryPublisher(logger logging.Logger) event.Publisher

NewMemoryPublisher creates a new in-memory event publisher

Types

type MemoryPublisher

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

MemoryPublisher is an in-memory implementation of the events.Publisher interface

func (*MemoryPublisher) ClearEvents

func (p *MemoryPublisher) ClearEvents()

ClearEvents clears all published events

func (*MemoryPublisher) GetEvents

func (p *MemoryPublisher) GetEvents() []event.Event

GetEvents returns all published events

func (*MemoryPublisher) Publish

func (p *MemoryPublisher) Publish(ctx context.Context, evt event.Event) error

Publish publishes an event to memory

func (*MemoryPublisher) Subscribe

func (p *MemoryPublisher) Subscribe(
	ctx context.Context,
	eventName string,
	handler func(ctx context.Context, event event.Event) error,
) error

Subscribe adds a handler for a specific event type

func (*MemoryPublisher) WithMaxEvents

func (p *MemoryPublisher) WithMaxEvents(maxEvents int) *MemoryPublisher

WithMaxEvents sets the maximum number of events to store

Jump to

Keyboard shortcuts

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