storage

package
v0.8.11 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongo

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

Mongo uses a mongodb for storage

func (*Mongo) CheckReady

func (m *Mongo) CheckReady() error

CheckReady checks to see if the service can connect

func (*Mongo) GetEvents

func (m *Mongo) GetEvents(coll, uuid string) ([]*StoredEvent, error)

GetEvents gets all events for a particular uuid in a particular collection

func (*Mongo) GetVersion

func (m *Mongo) GetVersion(coll, uuid string) int

GetVersion gets the most recently inserted event version or 0 on not found/error

func (*Mongo) IDs

func (m *Mongo) IDs(coll string) ([]string, error)

IDs gets all uuids in a particular collection

func (*Mongo) StoreEvent

func (m *Mongo) StoreEvent(coll, uuid, eventType, eventData string, version int) error

StoreEvent stores an event given the db, uuid, and version

type ReadRepository added in v0.4.0

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

ReadRepository is a generic repository for reads

func NewReadRepository added in v0.4.0

func NewReadRepository(n string,
	et map[string]func() ddd.Event,
	r func([]ddd.Event) ddd.Aggregate,
	s Storage) *ReadRepository

NewReadRepository gets a new generic repository for reads

func (*ReadRepository) All added in v0.4.0

func (r *ReadRepository) All() ([]ddd.Aggregate, error)

All gets all aggregates

func (*ReadRepository) Load added in v0.4.0

func (r *ReadRepository) Load(uuid string) (ddd.Aggregate, error)

Load reads out a specific aggregate with the given uuid

type Storage

type Storage interface {
	CheckReady() error
	IDs(collection string) ([]string, error)
	GetEvents(collection, uuid string) ([]*StoredEvent, error)
	GetVersion(collection, uuid string) int
	StoreEvent(collection, uuid, eventType, eventData string, version int) error
}

Storage is the basic interface for storing of event streams

func NewMongo

func NewMongo(conn, db string) (Storage, error)

NewMongo returns the Storage interface from the mongo driver

type StoredEvent

type StoredEvent struct {
	UUID      string
	Version   int
	Timestamp int64
	Type      string
	Data      string
}

StoredEvent represents an event in storage which includes its uuid, version, type, and event (as json)

type WriteRepository added in v0.4.0

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

WriteRepository is a generic repository for reads/writes

func NewWriteRepository added in v0.4.0

func NewWriteRepository(n string, s Storage) *WriteRepository

NewWriteRepository gets a new generic repository for reads/writes

func (*WriteRepository) Save added in v0.4.0

func (r *WriteRepository) Save(a ddd.Aggregate) error

Save persists the new events for the aggregate

Jump to

Keyboard shortcuts

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