Documentation ¶
Index ¶
- Variables
- func Copy(dst, src Store) error
- type BundleSetter
- type Codec
- type Directory
- func (s *Directory) Close()
- func (s *Directory) Closed() bool
- func (f *Directory) Exists(prefix, key string) bool
- func (s *Directory) GetCodec() Codec
- func (d *Directory) Keys(prefix string) ([]string, error)
- func (f *Directory) Load(prefix, key string, val interface{}) error
- func (d *Directory) MetaData() (res map[string]string)
- func (s *Directory) Name() string
- func (f *Directory) Open(codec Codec) error
- func (d *Directory) Prefixes() ([]string, error)
- func (s *Directory) ReadOnly() bool
- func (f *Directory) Remove(prefix, key string) error
- func (f *Directory) Save(prefix, key string, val interface{}) error
- func (d *Directory) SetMetaData(vals map[string]string) error
- func (s *Directory) SetReadOnly() bool
- func (d *Directory) Type() string
- type File
- func (s *File) Close()
- func (s *File) Closed() bool
- func (f *File) Exists(prefix, key string) bool
- func (s *File) GetCodec() Codec
- func (f *File) Keys(prefix string) ([]string, error)
- func (f *File) Load(prefix, key string, val interface{}) error
- func (f *File) MetaData() map[string]string
- func (s *File) Name() string
- func (f *File) Open(codec Codec) error
- func (f *File) Prefixes() ([]string, error)
- func (s *File) ReadOnly() bool
- func (f *File) Remove(prefix, key string) error
- func (f *File) Save(prefix, key string, val interface{}) error
- func (f *File) SetMetaData(vals map[string]string) error
- func (s *File) SetReadOnly() bool
- func (f *File) Type() string
- type Memory
- func (s *Memory) Close()
- func (s *Memory) Closed() bool
- func (m *Memory) Exists(prefix, key string) bool
- func (s *Memory) GetCodec() Codec
- func (m *Memory) Keys(prefix string) ([]string, error)
- func (m *Memory) Load(prefix, key string, val interface{}) error
- func (m *Memory) MetaData() map[string]string
- func (s *Memory) Name() string
- func (m *Memory) Open(codec Codec) error
- func (m *Memory) Prefixes() ([]string, error)
- func (s *Memory) ReadOnly() bool
- func (m *Memory) Remove(prefix, key string) error
- func (m *Memory) Save(prefix, key string, val interface{}) error
- func (m *Memory) SetMetaData(vals map[string]string) error
- func (s *Memory) SetReadOnly() bool
- func (m *Memory) Type() string
- type MetaSaver
- type NotFound
- type ReadOnlySetter
- type StackCannotBeOverridden
- type StackCannotOverride
- type StackPushError
- type StackedStore
- func (s *StackedStore) Close()
- func (s *StackedStore) Closed() bool
- func (s *StackedStore) Exists(prefix, key string) bool
- func (s *StackedStore) GetCodec() Codec
- func (s *StackedStore) ItemReadOnly(prefix, key string) (bool, bool)
- func (s *StackedStore) Keys(prefix string) ([]string, error)
- func (s *StackedStore) Layers() []Store
- func (s *StackedStore) Load(prefix, key string, val interface{}) error
- func (s *StackedStore) MetaFor(prefix, key string) map[string]string
- func (s *StackedStore) Name() string
- func (s *StackedStore) Open(codec Codec) error
- func (s *StackedStore) Prefixes() ([]string, error)
- func (s *StackedStore) Push(layer Store, keysCannotBeOverridden, keysCannotOverride bool) error
- func (s *StackedStore) ReadOnly() bool
- func (s *StackedStore) Remove(prefix, key string) error
- func (s *StackedStore) Save(prefix, key string, val interface{}) error
- func (s *StackedStore) SetReadOnly() bool
- func (s *StackedStore) Type() string
- type Store
- type UnWritable
Constants ¶
This section is empty.
Variables ¶
var DefaultCodec = JsonCodec
var JsonCodec = &codec{ enc: json.Marshal, dec: json.Unmarshal, ext: ".json", }
JsonCodec implements Codec for encoding/decoding to JSON.
var YamlCodec = &codec{ enc: yaml.Marshal, dec: yamlDecode, ext: ".yaml", }
YamlCodec implements a Codec for encoding/decoding to YAML
Functions ¶
Types ¶
type BundleSetter ¶
type BundleSetter interface {
SetBundle(string)
}
When loading an object, the store should set the current owner name.
type Codec ¶
type Codec interface { // Encode takes an object and turns it into a byte array. Encode(interface{}) ([]byte, error) // Decode takes a byte array and decodes it into an object Decode([]byte, interface{}) error // Ext is the file extension that should be used for this encoding // if we are encoding to a filesystem. Ext() string }
Codec is responsible for encoding and decoding raw Go objects into a serializable form.
type Directory ¶
type Directory struct { Path string // contains filtered or unexported fields }
Directory implements a Store that is backed by a local directory tree.
func (*Directory) SetReadOnly ¶
func (s *Directory) SetReadOnly() bool
type File ¶
type File struct { Path string // contains filtered or unexported fields }
func (*File) SetReadOnly ¶
func (s *File) SetReadOnly() bool
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
MemoryStore provides an in-memory implementation of Store for testing purposes
func (*Memory) SetReadOnly ¶
func (s *Memory) SetReadOnly() bool
type MetaSaver ¶
type MetaSaver interface { Store MetaData() map[string]string SetMetaData(map[string]string) error }
MetaSaver is a Store that is capable of of recording metadata about itself.
type ReadOnlySetter ¶
type ReadOnlySetter interface {
SetReadOnly(bool)
}
When loading an object, the store should set the current readonly state on the object.
type StackCannotBeOverridden ¶
type StackCannotBeOverridden string
func (StackCannotBeOverridden) Error ¶
func (s StackCannotBeOverridden) Error() string
type StackCannotOverride ¶
type StackCannotOverride string
func (StackCannotOverride) Error ¶
func (s StackCannotOverride) Error() string
type StackPushError ¶
type StackPushError string
func (StackPushError) Error ¶
func (s StackPushError) Error() string
type StackedStore ¶
type StackedStore struct {
// contains filtered or unexported fields
}
StackedStore is a store that represents the combination of several stores stacked together. The first store in the stack is the only one that is writable, and the rest are set as read-only. StackedStores are initially created empty.
func (*StackedStore) Exists ¶
func (s *StackedStore) Exists(prefix, key string) bool
func (*StackedStore) ItemReadOnly ¶
func (s *StackedStore) ItemReadOnly(prefix, key string) (bool, bool)
func (*StackedStore) Layers ¶
func (s *StackedStore) Layers() []Store
func (*StackedStore) Load ¶
func (s *StackedStore) Load(prefix, key string, val interface{}) error
func (*StackedStore) Open ¶
func (s *StackedStore) Open(codec Codec) error
func (*StackedStore) Prefixes ¶
func (s *StackedStore) Prefixes() ([]string, error)
func (*StackedStore) Push ¶
func (s *StackedStore) Push(layer Store, keysCannotBeOverridden, keysCannotOverride bool) error
Push adds a Store to the stack of stores in this stack. Any Store but the initial one will be marked as read-only. Either the Push call succeeds, or nothing about any of the Stores that are part of the Push operation change and the error contains details about what went wrong.
func (*StackedStore) ReadOnly ¶
func (s *StackedStore) ReadOnly() bool
func (*StackedStore) Remove ¶
func (s *StackedStore) Remove(prefix, key string) error
func (*StackedStore) Save ¶
func (s *StackedStore) Save(prefix, key string, val interface{}) error
func (*StackedStore) SetReadOnly ¶
func (s *StackedStore) SetReadOnly() bool
func (*StackedStore) Type ¶
func (s *StackedStore) Type() string
type Store ¶
type Store interface { sync.Locker RLock() RUnlock() // Open opens the store for use. Open(Codec) error // GetCodec returns the codec that the open store uses for marshalling and unmarshalling data GetCodec() Codec // Keys returns the list of keys that this store has in no // particular order. Keys(string) ([]string, error) // Subs returns a map all of the substores for this store. Prefixes() ([]string, error) // Test to see if a given entry exists Exists(string, string) bool // Load the data for a particular key Load(string, string, interface{}) error // Save data for a key Save(string, string, interface{}) error // Remove a key/value pair. Remove(string, string) error // ReadOnly returns whether a store is set to be read-only. ReadOnly() bool // SetReadOnly sets the store into read-only mode. This is a // one-way operation -- once a store is set to read-only, it // cannot be changed back to read-write while the store is open. SetReadOnly() bool // Close closes the store. Attempting to perfrom operations on // a closed store will panic. Close() // Closed returns whether or not a store is Closed Closed() bool // Type is the type of Store this is. Type() string // Name is the name of Store this is. Name() string }
Store provides an interface for some very basic key/value storage needs. Each Store (including ones created with MakeSub() should operate as separate, flat key/value stores.
func Open ¶
Open a store via URI style locator. Locators have the following formats:
storeType:path?codec=codecType&ro=false&option=foo for stores that always refer to something local, and
storeType://host:port/path?codec=codecType&ro=false&option=foo for stores that need to talk over the network.
All store types take codec and ro as optional parameters ¶
The following storeTypes are known:
- file, in which path refers to a single local file.
- directory, in which path refers to a top-level directory
- bolt, in which path refers to the directory where the Bolt database is located. bolt also takes an optional bucket parameter to specify the top-level bucket data is stored in.
- memory, in which path does not mean anything.
type UnWritable ¶
type UnWritable string
func (UnWritable) Error ¶
func (u UnWritable) Error() string