event

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 10 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventTypeNotFound = errors.New("event type not found")
)

Functions

func Register added in v0.10.2

func Register(ctx context.Context) error

func RegisterChannelQueue added in v0.8.0

func RegisterChannelQueue(ctx context.Context) error

Types

type ChannelQueue

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

func NewChannelQueue

func NewChannelQueue() *ChannelQueue

func (ChannelQueue) Pop

func (q ChannelQueue) Pop(events map[EventType]reflect.Type) (Event, error)

func (ChannelQueue) Push

func (q ChannelQueue) Push(e Event) error

type ChannelQueueConfig added in v0.10.2

type ChannelQueueConfig struct{}

func NewChannelQueueConfig added in v0.10.2

func NewChannelQueueConfig() *ChannelQueueConfig

func (*ChannelQueueConfig) Queue added in v0.10.2

func (c *ChannelQueueConfig) Queue() Queue

type Config added in v0.10.2

type Config interface {
	Queue() Queue
}

type Event

type Event interface {
	Type() EventType
	WithContext(ctx context.Context)
	Context(ctx context.Context) context.Context
}

type EventLogger added in v0.5.0

type EventLogger struct {
}

func (*EventLogger) Context added in v0.5.0

func (e *EventLogger) Context(ctx context.Context) context.Context

func (*EventLogger) WithContext added in v0.5.0

func (e *EventLogger) WithContext(ctx context.Context)

type EventService added in v0.8.0

type EventService struct {
	Queue  Queue                  `inject:""`
	Logger *slog.Logger           `inject:""`
	DP     *di.DependencyProvider `inject:""`
	// contains filtered or unexported fields
}

func Service added in v0.8.0

func Service(listeners ...*Listener) *EventService

func (*EventService) Name added in v0.8.0

func (s *EventService) Name() string

func (*EventService) Run added in v0.8.0

func (s *EventService) Run(ctx context.Context) error

type EventType

type EventType string

type Handler added in v0.8.0

type Handler[E Event] interface {
	Handle(ctx context.Context, event E) error
}

type Listener added in v0.8.0

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

func NewListener added in v0.8.0

func NewListener[H Handler[E], E Event]() *Listener

type Queue

type Queue interface {
	Push(e Event) error
	Pop(events map[EventType]reflect.Type) (Event, error)
}

type QueueConfiger added in v0.10.2

type QueueConfiger interface {
	QueueConfig() Config
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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