store

package
v0.0.0-...-cfbe396 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2015 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFieldRequired is returned when a field is required and receives a
	// request to be deleted.
	ErrFieldRequired = errors.New("field is required")

	// ErrMissingKey is returned when a key is missing
	ErrMissingKey = errors.New("key not found")

	// ErrMissingField is returned when a field is missing
	ErrMissingField = errors.New("no such field")

	// ErrMissingBackend is returned with a given backend is not found
	ErrMissingBackend = errors.New("backend not found")
)

Functions

This section is empty.

Types

type Backend

type Backend struct {
	store.Store

	Name   string
	Prefix string
}

Backend stores information about keys under backend, plus a name for the backend.

func NewBackend

func NewBackend(wraps store.Store, name, prefix string) *Backend

NewBackend wraps a backend for use in a store

func (*Backend) FieldKey

func (b *Backend) FieldKey(schema *app.Schema, field *app.Field) string

FieldKey returns the root for a schema and field

func (*Backend) SchemaKey

func (b *Backend) SchemaKey(schema *app.Schema) string

SchemaKey returns the root for a schema

type DecodeError

type DecodeError struct {
	Field string
	Err   error
}

DecodeError is returned for errors in decoding values

func (*DecodeError) Error

func (d *DecodeError) Error() string

type MultiError

type MultiError struct {
	// contains filtered or unexported fields
}

MultiError is multiple errors rolled into one

func NewMultiError

func NewMultiError(errs ...error) *MultiError

NewMultiError wraps a number of errors in a MutliError

func (*MultiError) Append

func (m *MultiError) Append(err error)

Append adds a new error onto the end of the MultiError

func (*MultiError) Error

func (m *MultiError) Error() string

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store stores and validates schemas.

func FromConfig

func FromConfig(src []byte) (*Store, error)

FromConfig loads a Store from config bytes

func New

func New(backends []*Backend, schemaStore, defaultStore *Backend) (*Store, error)

New returns a new Store with the given options

func (*Store) DeleteSchema

func (s *Store) DeleteSchema(name string) error

DeleteSchema removes a schema from the K/V tree

func (*Store) DeleteValue

func (s *Store) DeleteValue(schemaName, fieldName string) error

DeleteValue deletes a single value or sets it back to the default. If the value is required and does not have a default, this method will return an error.

func (*Store) DeleteValues

func (s *Store) DeleteValues(schemaName string) error

DeleteValues deletes all the values

func (*Store) ListSchemas

func (s *Store) ListSchemas() ([]*app.Schema, error)

ListSchemas gets a list of schemas

func (*Store) RetrieveSchema

func (s *Store) RetrieveSchema(name string) (*app.Schema, error)

RetrieveSchema gets a schema

func (*Store) RetrieveValue

func (s *Store) RetrieveValue(schemaName, fieldName string) (interface{}, error)

RetrieveValue retrieves a single designated value

func (*Store) RetrieveValues

func (s *Store) RetrieveValues(schemaName string) (map[string]interface{}, error)

RetrieveValues gets all the values from the backend in a map

func (*Store) StoreDefaultValues

func (s *Store) StoreDefaultValues(schemaName string) error

StoreDefaultValues stores the default values for an app

func (*Store) StoreSchema

func (s *Store) StoreSchema(name string, schema *app.Schema) error

StoreSchema stores or updates a schema and makes sure that the schema is valid before storage.

func (*Store) StoreValue

func (s *Store) StoreValue(schemaName, fieldName string, value interface{}) error

StoreValue stores a single value

func (*Store) StoreValues

func (s *Store) StoreValues(schemaName string, values map[string]interface{}) error

StoreValues stores all the values specified

Jump to

Keyboard shortcuts

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