Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
var NoData = noData{}
NoData is a model with no data to persist.
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 ¶
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 ¶
A StorageBatch persists a model to storage as part of a batch such as a transaction.