eventflow

package module
v0.0.0-...-74a79fa Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: MIT Imports: 0 Imported by: 9

README

eventflow

Event sourcing helpers for go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator interface {
	Apply(Event) error
}

type Bus

type Bus interface {
	Publisher
	Subscriber
}

type Commander

type Commander interface {
	Command(interface{}) (Event, error)
}

type Event

type Event struct {
	// primary identifier for aggregate, like "SomeAggregate" or narrowed "<userId>:SomeAggregate"
	// should be indexed
	RowID string
	// additional columns for aggregate, should be used for segregation/grouping
	// Example: "entity_name" => "foo", "other_id" => "abcd123"
	// should be indexed because most queries would sort/group on them
	Columns map[string]interface{}
	// type of the event, used by aggregators on subscribe
	Type EventType
	// should be indexed because most queries would sort by timestamp
	Timestamp int64
	// serialized event payload
	Data []byte
	// serializer/mapper used to encode data
	Mapper string
}

Event contains serialized state of particular event that happened it is applied by aggregator to evaluate to current state (after this event)

type EventType

type EventType string

type MemoryFlow

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

func InMemory

func InMemory() *MemoryFlow

func (*MemoryFlow) Publish

func (b *MemoryFlow) Publish(event Event) error

func (*MemoryFlow) Subscribe

func (b *MemoryFlow) Subscribe(aggregator Aggregator, types ...EventType)

type Publisher

type Publisher interface {
	Publish(Event) error
}

type Snapshot

type Snapshot struct {
	// primary identifier for aggregate, like "SomeAggregate" or narrowed "<userId>:SomeAggregate"
	// should be indexed
	RowID string
	// should be indexed because most queries would sort by timestamp
	Timestamp int64
	// serialized state of aggregates
	Data []byte
	// serializer/mapper used to encode data
	Mapper string
}

Snapshot contains serialized state of aggregates up to timestamp it can be used to speed up aggregate initialization

type Store

type Store interface {
	Save(event Event) error
}

type Subscriber

type Subscriber interface {
	Subscribe(Aggregator, ...EventType)
}

Jump to

Keyboard shortcuts

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