store

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) ([]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