Documentation
¶
Index ¶
- Variables
- type BaseEvent
- func (e BaseEvent) EventID() uuid.UUID
- func (e BaseEvent) EventName() string
- func (e BaseEvent) OccurredAt() time.Time
- func (e BaseEvent) SchemaVer() int32
- func (e BaseEvent) Validate() error
- func (e BaseEvent) WithCausation(id uuid.UUID) BaseEvent
- func (e BaseEvent) WithMeta(k, v string) BaseEvent
- func (e BaseEvent) WithSchema(ver int32) BaseEvent
- func (e BaseEvent) WithTrace(traceID, correlationID string) BaseEvent
- type Event
- type EventBuffer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidEventName = errors.New("invalid event name") ErrInvalidEventProducer = errors.New("invalid event producer") ErrInvalidEventTime = errors.New("invalid event time") ErrInvalidEventID = errors.New("invalid event id") ErrInvalidEventSchema = errors.New("invalid event schema version") )
Детализация причины (удобно для логов/диагностики)
View Source
var ErrInvalidEvent = errors.New("invalid event")
Sentinel error (удобно для errors.Is)
Functions ¶
This section is empty.
Types ¶
type BaseEvent ¶
type BaseEvent struct {
// Core
Name string
At time.Time
// Idempotency / tracing
ID uuid.UUID
TraceID string
CorrelationID string
CausationID uuid.UUID
// Compatibility
SchemaVersion int32
// Producer metadata
Producer string
// Extensible, non-PII
Meta map[string]string
}
BaseEvent — базовая мета-информация любого события. Не содержит бизнес-данных и не привязан к Kafka/Transport.
func MustBaseEvent ¶
MustBaseEvent — удобный хелпер для мест, где name/producer константы.
func NewBaseEvent ¶
NewBaseEvent — безопасный конструктор (UTC + UUID + schema v1).
func (BaseEvent) OccurredAt ¶
func (BaseEvent) Validate ¶
Validate — строгая проверка инвариантов события. Возвращает ErrInvalidEvent (sentinel) с детализацией причины.
func (BaseEvent) WithCausation ¶
WithCausation — указать "что стало причиной" (например, EventID родительского события или CommandID).
func (BaseEvent) WithSchema ¶
type EventBuffer ¶
type EventBuffer struct {
// contains filtered or unexported fields
}
func (*EventBuffer) Clear ¶
func (b *EventBuffer) Clear()
func (*EventBuffer) Len ¶
func (b *EventBuffer) Len() int
func (*EventBuffer) Peek ¶
func (b *EventBuffer) Peek() []Event
Peek — посмотреть без очистки (копия, чтобы снаружи не мутировали slice).
func (*EventBuffer) Record ¶
func (b *EventBuffer) Record(e Event)
Click to show internal directories.
Click to hide internal directories.