storage

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 8 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 Storage

type Storage interface {
	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)

Jump to

Keyboard shortcuts

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