file

package
v0.0.0-...-a355528 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSnapshot

func NewSnapshot(dir, name string) (store.Snapshot, error)

NewSnapshot returns an instance of the snapshot service where data is stored in the directory given. This is a simple implementation that assumes a single file for the entire snapshot.

func NewStore

func NewStore(typeName string, dir string) store.KV

NewStore creates a store of object with a typeName in the given directory. Instances of the type will be stored as files in this directory and named accordingly.

Types

type Store

type Store struct {
	Dir string

	// IDFunc is the function that generates the id.
	IDFunc func(interface{}) string
	// contains filtered or unexported fields
}

Store is an abstraction for writing and reading from entries in a file directory.

func (*Store) Close

func (s *Store) Close() error

Close implements io.Closer

func (*Store) Delete

func (s *Store) Delete(key interface{}) error

Delete deletes the object by id

func (*Store) Entries

func (s *Store) Entries() (<-chan store.Pair, error)

Entries returns the entries

func (*Store) Exists

func (s *Store) Exists(key interface{}) (bool, error)

Exists checks for existence

func (*Store) Key

func (s *Store) Key(key interface{}) string

Key returns an id given the key. The id contains type, etc.

func (*Store) Read

func (s *Store) Read(key interface{}) ([]byte, error)

Read checks for existence

func (*Store) Write

func (s *Store) Write(key interface{}, value []byte) error

Write writes the object and returns an id or error.

Jump to

Keyboard shortcuts

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