event

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyEvent = Event{}

Functions

func DataOf

func DataOf[T any](e Event) T

func From

func From(event Event) *entry

Types

type AggID

type AggID = ids.ID

type Aggregate

type Aggregate interface {
	ID() ids.ID
	Type() string
	Version() int
}

type Event

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

func For

func For[Data any](a Aggregate, name string, data Data, opts ...Option) Event

func New

func New(name string, data any, opts ...Option) Event

func (Event) Aggregate

func (e Event) Aggregate() (AggID, string, int)

func (Event) AggregateID added in v0.6.0

func (e Event) AggregateID() AggID

func (Event) Data

func (e Event) Data() interface{}

func (Event) ID

func (e Event) ID() ID

func (Event) MarshalBSON

func (e Event) MarshalBSON() ([]byte, error)

func (Event) Name

func (e Event) Name() string

func (Event) Time

func (e Event) Time() time.Time

func (*Event) UnmarshalBSON

func (e *Event) UnmarshalBSON(data []byte) error

func (Event) Version added in v0.2.2

func (e Event) Version() int

type ID

type ID = ids.ID

type IEvent

type IEvent interface {
	// ID returns the id of the event.
	ID() ID
	// Name returns the name of the event.
	Name() string
	// Time returns the time of the event.
	Time() time.Time
	// Data returns the event data.
	Data() interface{}
	// Aggregate returns the id, name and version of the aggregate that the
	// event belongs to. aggregate should return zero values if the event is not
	// an aggregate event.
	Aggregate() (id ids.ID, name string, version int)
}

type Metadata

type Metadata struct {
	ID               ID
	Name             string
	Time             time.Time
	AggregateName    string
	AggregateID      AggID
	AggregateVersion int
	Data             interface{}
}

type Option

type Option func(*Metadata)

func WithAggregate

func WithAggregate(a Aggregate) Option

func WithID

func WithID(id ID) Option

func WithTime

func WithTime(t time.Time) Option

func WithType added in v0.5.3

func WithType(id AggID, typeName string) Option

func WithTypeAndVersion added in v0.6.0

func WithTypeAndVersion(id AggID, typeName string, version int) Option

Jump to

Keyboard shortcuts

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