store

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EmptyEntityID represents an empty EntityID
	EmptyEntityID = EntityID("")
)

Variables

This section is empty.

Functions

func IsValidEntityID

func IsValidEntityID(entityID string) bool

Types

type Action

type Action struct {
	// Type of the action
	Type ActionType
	// EntityID of the instance in action
	EntityID EntityID
	// ModelName of the instance in action
	ModelName string
	// Previous is the instance before the action
	Previous interface{}
	// Current is the instance after the action was done
	Current interface{}
}

Action is a operation done in the model

type ActionType

type ActionType int

ActionType is the type used by actions done in a txn

const (
	// Create indicates the creation of an instance in a txn
	Create ActionType = iota
	// Save indicates the mutation of an instance in a txn
	Save
	// Delete indicates the deletion of an instance by ID in a txn
	Delete
)

type EntityID

type EntityID string

EntityID is the type used in models identities

func NewEntityID

func NewEntityID() EntityID

NewEntityID generates a new identity for an instance

func (EntityID) String

func (e EntityID) String() string

type Event

type Event interface {
	Time() []byte
	EntityID() EntityID
	Model() string
}

Event is a local or remote event generated in a model and dispatcher by Dispatcher.

type EventCodec

type EventCodec interface {
	// Reduce applies generated events into state
	Reduce(
		events []Event,
		datastore ds.TxnDatastore,
		baseKey ds.Key,
		indexFunc func(model string, key ds.Key, oldData, newData []byte, txn ds.Txn) error,
	) ([]ReduceAction, error)
	// Create corresponding events to be dispatched
	Create(ops []Action) ([]Event, format.Node, error)
	// EventsFromBytes deserializes a format.Node bytes payload into
	// Events.
	EventsFromBytes(data []byte) ([]Event, error)
}

EventCodec transforms actions generated in models to events dispatched to thread logs, and viceversa.

type ReduceAction

type ReduceAction struct {
	// Type of the reduced action
	Type ActionType
	// Model in which action was made
	Model string
	// EntityID of the instance in reduced action
	EntityID EntityID
}

Jump to

Keyboard shortcuts

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