Documentation
¶
Index ¶
- Constants
- Variables
- func Register(name string, create func(Config) (Backend, error))
- type Backend
- type Bucket
- type Config
- type Error
- type Object
- type Store
- func (s *Store) Bucket(name string) *Store
- func (s *Store) Fetch(obj Object) error
- func (s *Store) ForEach(handle func(Object) error) error
- func (s *Store) Get(key string) (Object, error)
- func (s *Store) GetWithPrefix(prefix string) ([]Object, error)
- func (s *Store) Keys() ([]string, error)
- func (s *Store) KeysWithPrefix(prefix string) ([]string, error)
- func (s *Store) List() (map[string]Object, error)
- func (s *Store) Path(key string) string
- func (s *Store) Put(obj Object) error
- func (s *Store) Remove(key string) error
- func (s *Store) Shutdown() error
Constants ¶
View Source
const DefaultStore = "local"
DefaultStore defines the default store backend.
Variables ¶
View Source
var ( // ErrObjectNotFound is returned when there is no object found. ErrObjectNotFound = Error{objNotFound, "Object not found"} // ErrBucketNotFound returns the error that no bucket found. ErrBucketNotFound = Error{bucketNotFound, "Bucket not found"} )
View Source
var (
// MetaJSONFile is the default name of json file.
MetaJSONFile = "meta.json"
)
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
// Put write key-value into store.
Put(bucket string, key string, value []byte) error
// Get read object from store.
Get(bucket string, key string) ([]byte, error)
// Remove remove all data of the key.
Remove(bucket string, key string) error
// List return all objects with specify bucket.
List(bucket string) ([][]byte, error)
// Keys return all keys.
Keys(bucket string) ([]string, error)
// Path returns the path with the specified key.
Path(key string) string
// Close releases all resources used by the store
// It does not make any changes to store.
Close() error
}
Backend is an interface which describes what a store should support.
func NewLocalStore ¶
NewLocalStore is used to make local metadata store instance.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a type of error used for meta.
func (Error) IsNotfound ¶
IsNotfound return true if code in MetaError is objNotfound.
type Store ¶
type Store struct {
Config
// contains filtered or unexported fields
}
Store defines what a metadata store should be like.
func (*Store) Bucket ¶
Bucket returns a specific store instance. And name is used to specify the bucket's name that will be write.
func (*Store) GetWithPrefix ¶
GetWithPrefix return objects matching prefix.
func (*Store) KeysWithPrefix ¶
KeysWithPrefix return all keys matching prefix.
Click to show internal directories.
Click to hide internal directories.