memdb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package memdb is an entirely in-memory database with no persistence and no concurrency guarantees. Its function is to provide a full database implementation to tests to run against.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (db.DB, error)

New returns a usable memdb with internal structures initialized.

Types

type MemDB

type MemDB struct {
	// contains filtered or unexported fields
}

The MemDB type binds the methods of this "database". This DB is designed really only for supporting the tests of other modules, so keep in mind that it is not safe for concurrent execution.

func (*MemDB) DeleteEntity

func (m *MemDB) DeleteEntity(ID string) error

DeleteEntity deletes an entity from the "database".

func (*MemDB) DeleteGroup

func (m *MemDB) DeleteGroup(name string) error

DeleteGroup deletes a group from the "database".

func (*MemDB) DiscoverEntityIDs

func (m *MemDB) DiscoverEntityIDs() ([]string, error)

DiscoverEntityIDs returns a list of entity IDs which can then be used to load particular entities.

func (*MemDB) DiscoverGroupNames

func (m *MemDB) DiscoverGroupNames() ([]string, error)

DiscoverGroupNames returns a slice of strings that can be later used to load groups.

func (*MemDB) LoadEntity

func (m *MemDB) LoadEntity(ID string) (*pb.Entity, error)

LoadEntity loads an entity from the "database".

func (*MemDB) LoadGroup

func (m *MemDB) LoadGroup(name string) (*pb.Group, error)

LoadGroup loads a group from the "database".

func (*MemDB) NextEntityNumber added in v0.0.12

func (m *MemDB) NextEntityNumber() (int32, error)

NextEntityNumber fetches out the next unassigned entity number.

func (*MemDB) NextGroupNumber added in v0.0.12

func (m *MemDB) NextGroupNumber() (int32, error)

NextGroupNumber uses the util package to return a group number.

func (*MemDB) SaveEntity

func (m *MemDB) SaveEntity(e *pb.Entity) error

SaveEntity saves an entity to the "database".

func (*MemDB) SaveGroup

func (m *MemDB) SaveGroup(g *pb.Group) error

SaveGroup saves a group to the "database".

func (*MemDB) SearchEntities added in v0.0.12

func (m *MemDB) SearchEntities(r db.SearchRequest) ([]*pb.Entity, error)

SearchEntities returns a slice of entity given a searchrequest.

func (*MemDB) SearchGroups added in v0.0.12

func (m *MemDB) SearchGroups(r db.SearchRequest) ([]*pb.Group, error)

SearchGroups returns a slice of entity given a searchrequest.

Jump to

Keyboard shortcuts

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