storage

package
v0.0.6-rc2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrModelRepositorySerialisation must be used when document repository encounters a marshalling error
	ErrModelRepositorySerialisation = errors.Error("model repository encountered a marshalling error")

	// ErrModelRepositoryNotFound must be used when model is not found in db
	ErrModelRepositoryNotFound = errors.Error("model not found in db")

	// ErrRepositoryModelSave must be used when db repository can not save the given model
	ErrRepositoryModelSave = errors.Error("db repository could not save the given model")

	// ErrRepositoryModelUpdateKeyNotFound must be used when db repository can not update the given model
	ErrRepositoryModelUpdateKeyNotFound = errors.Error("db repository could not update the given model, key not found")

	// ErrRepositoryModelCreateKeyExists must be used when db repository can not create the given model
	ErrRepositoryModelCreateKeyExists = errors.Error("db repository could not create the given model, key already exists")

	// ErrModelTypeNotRegistered must be used when model hasn't been registered in db
	ErrModelTypeNotRegistered = errors.Error("type not registered")
)
View Source
const (
	// BootstrappedDB is a key mapped to DB at boot
	BootstrappedDB string = "BootstrappedDB"
	// BootstrappedConfigDB is a key mapped to DB for configs at boot
	BootstrappedConfigDB string = "BootstrappedConfigDB"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model interface {
	//Returns the underlying type of the Model
	Type() reflect.Type

	// JSON return the json representation of the model
	JSON() ([]byte, error)

	// FromJSON initialize the model with a json
	FromJSON(json []byte) error
}

Model is an interface to abstract away storage model specificness

type Repository

type Repository interface {
	Register(model Model)
	Exists(key []byte) bool
	Get(key []byte) (Model, error)
	GetAllByPrefix(prefix string) ([]Model, error)
	Create(key []byte, model Model) error
	Update(key []byte, model Model) error
	Delete(key []byte) error
	Close() error
}

Repository defines the required methods for standard storage repository.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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