db

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownEntity is returned for requests to load an entity
	// that does not exist.
	ErrUnknownEntity = errors.New("The specified entity does not exist")

	// ErrUnknownGroup is returned for requests to load a group
	// that does not exist.
	ErrUnknownGroup = errors.New("The specified group does not exist")

	// ErrUnknownDatabase is returned for an attempt to create a
	// new database that hasn't been registered.
	ErrUnknownDatabase = errors.New("The specified database does not exist")

	// ErrInternalError is used for all other errors that occur
	// within a database implementation.
	ErrInternalError = errors.New("The database has encountered an internal error")
)

Functions

func GetBackendList

func GetBackendList() []string

GetBackendList returns a string list of the backends that are available

func Register added in v0.0.10

func Register(name string, newFunc Factory)

Register takes in a name of the database to register and a function signature to bind to that name.

Types

type DB

type DB interface {
	// Entity handling
	DiscoverEntityIDs() ([]string, error)
	LoadEntity(string) (*pb.Entity, error)
	SaveEntity(*pb.Entity) error
	DeleteEntity(string) error

	// Group handling
	DiscoverGroupNames() ([]string, error)
	LoadGroup(string) (*pb.Group, error)
	SaveGroup(*pb.Group) error
	DeleteGroup(string) error
}

DB specifies the methods that a DB engine must provide.

func New

func New(name string) (DB, error)

New returns a db struct.

type Factory

type Factory func() (DB, error)

Factory defines the function which can be used to register new implementations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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