event

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package event provides concrete event types for the sync kit.

The Event struct is a ready-to-use implementation of the synckit/types.Event interface, with support for standard fields: ID, Type, AggregateID, Data, Metadata, and Timestamp. Use New() or NewWithMetadata() to create events.

See also:

Package event provides concrete event types for the sync kit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// EventID is the unique identifier for this event
	EventID string `json:"id"`

	// EventType represents the event type (e.g., "UserCreated", "OrderUpdated")
	EventType string `json:"type"`

	// EventAggregateID is the ID of the aggregate this event belongs to
	EventAggregateID string `json:"aggregate_id"`

	// EventData contains the event payload as raw bytes
	EventData []byte `json:"data"`

	// EventMetadata contains additional event metadata
	EventMetadata map[string]interface{} `json:"metadata,omitempty"`

	// Timestamp records when the event was created
	Timestamp time.Time `json:"timestamp"`

	// Offset is set by the event store to track event ordering
	Offset int64 `json:"offset,omitempty"`
}

Event represents a concrete implementation of the Event interface. It provides a simple, ready-to-use event structure for most use cases.

func New

func New(id, eventType, aggregateID string, data []byte) *Event

New creates a new Event with the given parameters.

func NewWithMetadata

func NewWithMetadata(id, eventType, aggregateID string, data []byte, metadata map[string]interface{}) *Event

NewWithMetadata creates a new Event with the given parameters and metadata.

func (*Event) AggregateID

func (e *Event) AggregateID() string

AggregateID returns the ID of the aggregate this event belongs to.

func (*Event) Data

func (e *Event) Data() interface{}

Data returns the event payload.

func (*Event) ID

func (e *Event) ID() string

ID returns the unique identifier for this event.

func (*Event) Metadata

func (e *Event) Metadata() map[string]interface{}

Metadata returns additional event metadata.

func (*Event) Type

func (e *Event) Type() string

Type returns the event type.

Jump to

Keyboard shortcuts

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