model

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedSchemaVersion = errors.New("model does not support requested schema version")

ErrUnsupportedSchemaVersion is returned when a Persistable model cannot be persisted in a particular schema version.

View Source
var NoData = noData{}

NoData is a model with no data to persist.

View Source
var OldestSupportedSchemaVersion = Version{Major: 0, Patch: 28}

OldestSupportedSchemaVersion is the oldest version of the schema that lily can convert its models to Models can be persisted using any version between this and the latest version. Version 28 is the version in which support for multiple schemas was introduced.

Functions

func VersionCmp

func VersionCmp(a, b Version) int

VersionCmp compares versions a and b and returns -1 if a < b, +1 if a > b and 0 if they are equal

Types

type Persistable

type Persistable interface {
	Persist(ctx context.Context, s StorageBatch, version Version) error
}

A Persistable can persist a full copy of itself or its components as part of a storage batch using a specific version of a schema. Persist should call PersistModel on s with a model containing data that should be persisted. ErrUnsupportedSchemaVersion should be retuned if the Persistable cannot provide a model compatible with the requested schema version. If the model does not exist in the schema version because it has been removed or was added in a later version then Persist should be a no-op and return nil.

type PersistableList

type PersistableList []Persistable

A PersistableList is a list of Persistables that should be persisted together

func (PersistableList) Persist

func (pl PersistableList) Persist(ctx context.Context, s StorageBatch, version Version) error

type Storage

type Storage interface {
	PersistBatch(ctx context.Context, ps ...Persistable) error
}

A Storage can marshal models into a serializable format and persist them.

type StorageBatch

type StorageBatch interface {
	PersistModel(ctx context.Context, m interface{}) error
}

A StorageBatch persists a model to storage as part of a batch such as a transaction.

type Version

type Version struct {
	Major int
	Patch int
}

A Version represents a version of a model schema

func ParseVersion

func ParseVersion(s string) (Version, error)

func (Version) Before

func (v Version) Before(v2 Version) bool

Before reports whether v should be ordered before v2

func (Version) String

func (v Version) String() string

Directories

Path Synopsis
actors

Jump to

Keyboard shortcuts

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