eventstore

package
v0.0.0-...-4581c0e Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventStore

type EventStore interface {
	Save(ctx context.Context, groupId string, aggregateId string, events []event.Event) (concurrencyException bool, err error)
	SaveSnapshot(ctx context.Context, groupId string, aggregateId string, event event.Event) (concurrencyException bool, err error)
	LoadUpToVersion(ctx context.Context, queries []VersionQuery, eventHandler event.Handler) error
	LoadFromVersion(ctx context.Context, queries []VersionQuery, eventHandler event.Handler) error
	LoadFromSnapshot(ctx context.Context, queries []SnapshotQuery, eventHandler event.Handler) error
	RemoveUpToVersion(ctx context.Context, queries []VersionQuery) error
}

EventStore provides interface over eventstore. More aggregates can be grouped by groupId, but aggregateId of aggregates must be unique against whole DB.

type FactoryModelFunc

type FactoryModelFunc func(ctx context.Context) (Model, error)

FactoryModelFunc creates user model.

type GoroutinePoolGoFunc

type GoroutinePoolGoFunc func(func()) error

GoroutinePoolGoFunc processes actions via provided function

type LogDebugfFunc

type LogDebugfFunc func(fmt string, args ...interface{})

LogDebugfFunc log debug messages

type Model

type Model interface {
	event.Handler
	SnapshotEventType() string
}

Model user defined model where events from eventstore will be projected.

type Projection

type Projection struct {
	LogDebugfFunc LogDebugfFunc
	// contains filtered or unexported fields
}

Projection projects events from eventstore to user model.

func NewProjection

func NewProjection(store EventStore, factoryModel FactoryModelFunc, LogDebugfFunc LogDebugfFunc) *Projection

NewProjection projection over eventstore.

func (*Projection) Forget

func (p *Projection) Forget(queries []SnapshotQuery) (err error)

Forget drop projection by query.Verson in Query is ignored.

func (*Projection) Handle

func (p *Projection) Handle(ctx context.Context, iter event.Iter) error

Handle update projection by events.

func (*Projection) HandleWithReload

func (p *Projection) HandleWithReload(ctx context.Context, iter event.Iter) error

HandleWithReload update projection by events and reload events if it is needed.

func (*Projection) Models

func (p *Projection) Models(queries []SnapshotQuery) []Model

Models return models from projection.

func (*Projection) Project

func (p *Projection) Project(ctx context.Context, queries []SnapshotQuery) (err error)

Project update projection from snapshots defined by query. Verson in Query is ignored.

type SnapshotQuery

type SnapshotQuery struct {
	GroupId           string //filter by group Id and it is used only when aggreagateId is empty
	AggregateId       string //filter to certain aggregateId
	SnapshotEventType string //required
}

SnapshotQuery used to load events from snapshot.

type VersionQuery

type VersionQuery struct {
	AggregateId string //required
	Version     uint64 //required
}

VersionQuery used to load events from version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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