sus

package
v0.0.0-...-3291bb5 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2015 License: MIT, MIT Imports: 5 Imported by: 0

README

sus

A simple pkg providing storage for entities that require sequential updating.

Test Coverage

Docs

Documentation

Overview

Package sus provides data storage for entities that require sequential updates. Any type of datastore can be created in the same manner as those available by default in sus, Memory/File/AppEngine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteGetter

type ByteGetter func(id string) ([]byte, error)

type BytePutter

type BytePutter func(id string, d []byte) error

type DeleteMulti

type DeleteMulti func(ids []string) error

type Deleter

type Deleter func(id string) error

type EntityInitializer

type EntityInitializer func(v Version) Version

type GetMulti

type GetMulti func(ids []string) ([]Version, error)

type IdFactory

type IdFactory func() string

type IsNonExtantError

type IsNonExtantError func(error) bool

type Marshaler

type Marshaler func(src Version) ([]byte, error)

type PutMulti

type PutMulti func(ids []string, vs []Version) error

type RunInTransaction

type RunInTransaction func(tran Transaction) error

type Store

type Store interface {
	Create() (id string, v Version, err error)
	CreateMulti(count uint) (ids []string, vs []Version, err error)
	Read(id string) (v Version, err error)
	ReadMulti(ids []string) (vs []Version, err error)
	Update(id string, v Version) error
	UpdateMulti(ids []string, vs []Version) error
	Delete(id string) error
	DeleteMulti(ids []string) error
}

The core sus interface.

func NewFileStore

func NewFileStore(storeDir string, fileExt string, m Marshaler, un Unmarshaler, idf IdFactory, vf VersionFactory, ei EntityInitializer) (Store, error)

Creates and configures a store that stores entities by converting them to and from []byte and keeps them in the local file system.

func NewJsonFileStore

func NewJsonFileStore(storeDir string, idf IdFactory, vf VersionFactory, ei EntityInitializer) (Store, error)

Creates and configures a store that stores entities by converting them to and from json []byte data and keeps them in the local file system.

func NewJsonMemoryStore

func NewJsonMemoryStore(idf IdFactory, vf VersionFactory, ei EntityInitializer) Store

Creates and configures a store that stores entities by converting them to and from json []byte data and keeps them in the local system memory.

func NewMemoryStore

func NewMemoryStore(m Marshaler, un Unmarshaler, idf IdFactory, vf VersionFactory, ei EntityInitializer) Store

Creates and configures a store that stores entities by converting them to and from []byte and keeps them in the local system memory.

func NewMutexByteStore

Creates and configures a store that stores entities by converting them to and from []byte and ensures versioning correctness with mutex locks.

func NewStore

Create and configure a core store.

type Transaction

type Transaction func() error

type Unmarshaler

type Unmarshaler func(data []byte, dst Version) error

type Version

type Version interface {
	GetVersion() int
	IncrementVersion()
	DecrementVersion()
}

The interface that struct entities must include as anonymous fields in order to be used with sus stores.

type VersionFactory

type VersionFactory func() Version

Jump to

Keyboard shortcuts

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