Documentation
¶
Overview ¶
Package events provides a lightweight, thread-safe, in-process event emitter for decoupling controllers from side-effects (emails, audit logs, etc.).
Index ¶
- Variables
- type BaseEvent
- type Emitter
- func (e *Emitter) Emit(ctx context.Context, event Event)
- func (e *Emitter) EmitAsync(ctx context.Context, event Event)
- func (e *Emitter) EmitPayload(ctx context.Context, eventName string, data any)
- func (e *Emitter) Off(eventName string, listener Listener)
- func (e *Emitter) On(eventName string, listener Listener)
- func (e *Emitter) OnFunc(eventName string, fn func(ctx context.Context, event Event) error)
- func (e *Emitter) OnPayload(eventName string, fn func(data any))
- func (e *Emitter) Once(eventName string, listener Listener)
- type Event
- type JobFailedEvent
- type JobProcessedEvent
- type JobProcessingEvent
- type JobQueuedEvent
- type Listener
- type ListenerFunc
- type MailSendingEvent
- type MailSentEvent
- type QueryExecutedEvent
- type RedisCommandExecutedEvent
- type RequestFinishedEvent
- type RequestStartedEvent
- type ServerStartedEvent
- type ServerStartingEvent
- type ServerStoppedEvent
- type ServerStoppingEvent
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultEmitter = New()
DefaultEmitter is the package-level default emitter.
Functions ¶
This section is empty.
Types ¶
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Emitter is a thread-safe in-process event bus.
func (*Emitter) EmitAsync ¶
EmitAsync fires all listeners for the given event using a fixed worker pool.
func (*Emitter) EmitPayload ¶
EmitPayload fires an event with a simple string name and any data.
type JobFailedEvent ¶
func (JobFailedEvent) Data ¶
func (e JobFailedEvent) Data() any
func (JobFailedEvent) Name ¶
func (e JobFailedEvent) Name() string
type JobProcessedEvent ¶
func (JobProcessedEvent) Data ¶
func (e JobProcessedEvent) Data() any
func (JobProcessedEvent) Name ¶
func (e JobProcessedEvent) Name() string
type JobProcessingEvent ¶
func (JobProcessingEvent) Data ¶
func (e JobProcessingEvent) Data() any
func (JobProcessingEvent) Name ¶
func (e JobProcessingEvent) Name() string
type JobQueuedEvent ¶
Queue events
func (JobQueuedEvent) Data ¶
func (e JobQueuedEvent) Data() any
func (JobQueuedEvent) Name ¶
func (e JobQueuedEvent) Name() string
type ListenerFunc ¶
ListenerFunc is a helper to use functions as listeners.
type MailSendingEvent ¶
Mail events
func (MailSendingEvent) Data ¶
func (e MailSendingEvent) Data() any
func (MailSendingEvent) Name ¶
func (e MailSendingEvent) Name() string
type MailSentEvent ¶
func (MailSentEvent) Data ¶
func (e MailSentEvent) Data() any
func (MailSentEvent) Name ¶
func (e MailSentEvent) Name() string
type QueryExecutedEvent ¶
DB events
func (QueryExecutedEvent) Data ¶
func (e QueryExecutedEvent) Data() any
func (QueryExecutedEvent) Name ¶
func (e QueryExecutedEvent) Name() string
type RedisCommandExecutedEvent ¶
type RedisCommandExecutedEvent struct {
Command string
Args []any
Duration time.Duration
Error error
}
Redis events
func (RedisCommandExecutedEvent) Data ¶
func (e RedisCommandExecutedEvent) Data() any
func (RedisCommandExecutedEvent) Name ¶
func (e RedisCommandExecutedEvent) Name() string
type RequestFinishedEvent ¶
func (RequestFinishedEvent) Data ¶
func (e RequestFinishedEvent) Data() any
func (RequestFinishedEvent) Name ¶
func (e RequestFinishedEvent) Name() string
type RequestStartedEvent ¶
Request lifecycle events
func (RequestStartedEvent) Data ¶
func (e RequestStartedEvent) Data() any
func (RequestStartedEvent) Name ¶
func (e RequestStartedEvent) Name() string
type ServerStartedEvent ¶
type ServerStartedEvent struct {
Addr string
}
func (ServerStartedEvent) Data ¶
func (e ServerStartedEvent) Data() any
func (ServerStartedEvent) Name ¶
func (e ServerStartedEvent) Name() string
type ServerStartingEvent ¶
type ServerStartingEvent struct {
Addr string
}
Server lifecycle events
func (ServerStartingEvent) Data ¶
func (e ServerStartingEvent) Data() any
func (ServerStartingEvent) Name ¶
func (e ServerStartingEvent) Name() string
type ServerStoppedEvent ¶
type ServerStoppedEvent struct{}
func (ServerStoppedEvent) Data ¶
func (e ServerStoppedEvent) Data() any
func (ServerStoppedEvent) Name ¶
func (e ServerStoppedEvent) Name() string
type ServerStoppingEvent ¶
type ServerStoppingEvent struct {
Signal string
}
func (ServerStoppingEvent) Data ¶
func (e ServerStoppingEvent) Data() any
func (ServerStoppingEvent) Name ¶
func (e ServerStoppingEvent) Name() string
Click to show internal directories.
Click to hide internal directories.