goes

package module
v0.0.0-...-ebe1b00 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2017 License: MIT Imports: 5 Imported by: 0

README

goes

Golang Event Store

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate interface {
	GetAggregateBase() *AggregateBase
}

Aggregate interface

type AggregateBase

type AggregateBase struct {
	ID       string
	Type     string
	Revision int
	Version  int
	Time     int64
	// contains filtered or unexported fields
}

AggregateBase entity

func (*AggregateBase) AddEvent

func (a *AggregateBase) AddEvent(eventType string, eventData interface{})

AddEvent add and apply event

func (*AggregateBase) DecodeEvent

func (a *AggregateBase) DecodeEvent(data []byte, v interface{}) error

DecodeEvent decode event data

func (*AggregateBase) GetAggregateBase

func (a *AggregateBase) GetAggregateBase() *AggregateBase

GetAggregateBase return AggregateBase

type ApplyFunc

type ApplyFunc func(e Event) error

ApplyFunc event handler func

type Encoder

type Encoder interface {
	Encode(v interface{}) ([]byte, error)
	Decode(data []byte, vPtr interface{}) error
}

Encoder encode and decode event data

type Event

type Event struct {
	AggregateID   string `json:"aggregateID" dynamodbav:"aggregateID" db:"aggregateID" msg:"a"`
	AggregateType string `json:"aggregateType" dynamodbav:"aggregateType" db:"aggregateType" msg:"b"`
	EventID       string `json:"eventID" dynamodbav:"eventID" db:"eventID" msg:"c"`
	EventType     string `json:"eventType" dynamodbav:"eventType" db:"eventType" msg:"d"`
	Revision      int    `json:"revision" dynamodbav:"revision" db:"revision" msg:"e"`
	Time          int64  `json:"time" dynamodbav:"time" db:"time" msg:"f"`
	Data          []byte `json:"data" dynamodbav:"data" db:"data" msg:"g"`
}

Event entity

func (*Event) DecodeMsg

func (z *Event) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Event) EncodeMsg

func (z *Event) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Event) MarshalMsg

func (z *Event) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Event) Msgsize

func (z *Event) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Event) UnmarshalMsg

func (z *Event) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type EventStore

type EventStore interface {
	NewAggregateBase(id string, aggtype string, version int, applyFunc ApplyFunc) *AggregateBase
	GetStream(a Aggregate) error
	GetStreamWithSnapshot(a Aggregate) error
	Commit(a Aggregate) error
	SaveSnapshot(a Aggregate) error
}

EventStore interface

func NewEventStore

func NewEventStore(storage Storage, encoder Encoder, idgen IDGen) EventStore

NewEventStore create new event store

type IDGen

type IDGen interface {
	Generate() string
}

IDGen interface

type Snapshot

type Snapshot struct {
	AggregateID      string `json:"aggregateID" dynamodbav:"aggregateID" db:"aggregateID"`
	AggregateType    string `json:"aggregateType" dynamodbav:"aggregateType" db:"aggregateType"`
	AggregateVersion int    `json:"aggregateVersion" dynamodbav:"aggregateVersion" db:"aggregateVersion"`
	Revision         int    `json:"revision" dynamodbav:"revision" db:"revision"`
	Time             int64  `json:"time" dynamodbav:"time" db:"time"`
	Data             []byte `json:"data" dynamodbav:"data" db:"data"`
}

Snapshot entity

type Storage

type Storage interface {
	Save(es []Event) error
	GetLastEvent(id string) ([]Event, error)
	SaveSnapshot(snap *Snapshot) error
	GetSnapshot(id string, version int) (*Snapshot, error)
	GetFromRevision(id string, from int) ([]Event, error)
	GetUndispatchedEvent() ([]Event, error)
	MarkDispatchedEvent(es []Event) error
}

Storage interface

type UUIDV4

type UUIDV4 struct{}

UUIDV4 uuid version 4

func NewUUIDV4

func NewUUIDV4() *UUIDV4

NewUUIDV4 new uuid v1

func (*UUIDV4) Generate

func (u *UUIDV4) Generate() string

Generate uuid v1

Directories

Path Synopsis
encoder
storage

Jump to

Keyboard shortcuts

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