Documentation
¶
Index ¶
- Constants
- Variables
- func NewMemoryPublisher(logger logging.Logger) event.Publisher
- type MemoryPublisher
- func (p *MemoryPublisher) ClearEvents()
- func (p *MemoryPublisher) GetEvents() []event.Event
- func (p *MemoryPublisher) Publish(ctx context.Context, evt event.Event) error
- func (p *MemoryPublisher) Subscribe(ctx context.Context, eventName string, ...) error
- func (p *MemoryPublisher) WithMaxEvents(maxEvents int) *MemoryPublisher
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 ¶
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) 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
Click to show internal directories.
Click to hide internal directories.