protodb

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package protodb is one of the simplest databases that just reads and writes protos to the local disk. It's probably quite usable in environments that don't have high modification rates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (db.DB, error)

New returns a new ProtoDB instance that is initialized and ready for use. This function will attempt to set up the data directory and fail out if it does not have permissions to write/stat the base directory and children. This function will bail out the entire program as without the backing store the functionality of the rest of the server is undefined!

Types

type ProtoDB

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

The ProtoDB type binds all methods that are a part of the protodb package.

func (*ProtoDB) DeleteEntity

func (pdb *ProtoDB) DeleteEntity(ID string) error

DeleteEntity removes an entity from disk. This is rather simple to do given that each entity is owned by exactly one file on disk. Simply removing the file is sufficient to delete the entity.

func (*ProtoDB) DeleteGroup

func (pdb *ProtoDB) DeleteGroup(name string) error

DeleteGroup removes a group from disk. This is rather simple to do given that each group is owned by exactly one file on disk. Simply removing the file is sufficient to delete the entity.

func (*ProtoDB) DiscoverEntityIDs

func (pdb *ProtoDB) DiscoverEntityIDs() ([]string, error)

DiscoverEntityIDs returns a list of entity IDs that this loader can retrieve by globbing the entity directory of the data_root. This is not foolproof, but assuming that the data_root is not modified by hand it should be safe enough.

func (*ProtoDB) DiscoverGroupNames

func (pdb *ProtoDB) DiscoverGroupNames() ([]string, error)

DiscoverGroupNames returns a list of group names that this loader can retrieve by globbing the group directory of the data_root. This is not foolproof, but assuming that the data_root is not modified by hand it should be safe enough.

func (*ProtoDB) LoadEntity

func (pdb *ProtoDB) LoadEntity(ID string) (*pb.Entity, error)

LoadEntity loads a single entity from the data_root given the ID associated with the entity.

func (*ProtoDB) LoadGroup

func (pdb *ProtoDB) LoadGroup(name string) (*pb.Group, error)

LoadGroup attempts to load a group by name from the disk. It can fail on proto errors or bogus file permissions reading the file.

func (*ProtoDB) NextEntityNumber added in v0.0.12

func (pdb *ProtoDB) NextEntityNumber() (int32, error)

NextEntityNumber computes and return the next entity number.

func (*ProtoDB) NextGroupNumber added in v0.0.12

func (pdb *ProtoDB) NextGroupNumber() (int32, error)

NextGroupNumber computes the next available group number. This is very inefficient but it only is called when a new group is being created, which is hopefully infrequent.

func (*ProtoDB) SaveEntity

func (pdb *ProtoDB) SaveEntity(e *pb.Entity) error

SaveEntity writes an entity to disk. Errors may be returned for proto marshal errors or for errors writing to disk. No promises are made regarding if the data has been written to disk at the return of this function as the operatig system may choose to buffer the data until a larger block may be written.

func (*ProtoDB) SaveGroup

func (pdb *ProtoDB) SaveGroup(g *pb.Group) error

SaveGroup writes an group to disk. Errors may be returned for proto marshal errors or for errors writing to disk. No promises are made regarding if the data has been written to disk at the return of this function as the operatig system may choose to buffer the data until a larger block may be written.

func (*ProtoDB) SearchEntities added in v0.0.12

func (pdb *ProtoDB) SearchEntities(r db.SearchRequest) ([]*pb.Entity, error)

SearchEntities returns a slice of entity given a searchrequest.

func (*ProtoDB) SearchGroups added in v0.0.12

func (pdb *ProtoDB) 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