eventsourcing

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 4 Imported by: 0

README

go-eventstore

How to use it

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStorageNotAvailable = errors.New("storage not available")
	ErrNoAggregateID       = errors.New("no aggregate id")
)

Functions

This section is empty.

Types

type Aggregate

type Aggregate interface {
	AggregateID() AggregateID
	On(e Event) error
	OnRaw(name string, version string, e []byte) error
	Events() []Event
}

type AggregateID

type AggregateID string

type Event

type Event interface {
	Meta() Meta
}

type EventID

type EventID string

type EventStore

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

func NewEventStore

func NewEventStore(l logrus.FieldLogger) *EventStore

func (*EventStore) AddStorage

func (es *EventStore) AddStorage(s Storage)

func (*EventStore) Load

func (es *EventStore) Load(storage string, a Aggregate) error

func (*EventStore) Persist

func (es *EventStore) Persist(storage string, a Aggregate) error

type Meta

type Meta struct {
	ID        EventID   `json:"id" yaml:"id"`
	Name      string    `json:"name" yaml:"name"`
	CreatedAt time.Time `json:"created_at" yaml:"created_at"`
	Version   string    `json:"version" yaml:"version"`
}

func NewMeta

func NewMeta(name string, version string) Meta

func NewMetaWithID

func NewMetaWithID(id EventID, name string, version string) Meta

type Storage

type Storage interface {
	Name() string
	Upsert(a Aggregate) error
	Load(a Aggregate) error
	Close() error
}

Jump to

Keyboard shortcuts

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