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 ¶
- func New() (db.DB, error)
- type ProtoDB
- func (pdb *ProtoDB) DeleteEntity(ID string) error
- func (pdb *ProtoDB) DeleteGroup(name string) error
- func (pdb *ProtoDB) DiscoverEntityIDs() ([]string, error)
- func (pdb *ProtoDB) DiscoverGroupNames() ([]string, error)
- func (pdb *ProtoDB) LoadEntity(ID string) (*pb.Entity, error)
- func (pdb *ProtoDB) LoadGroup(name string) (*pb.Group, error)
- func (pdb *ProtoDB) NextEntityNumber() (int32, error)
- func (pdb *ProtoDB) NextGroupNumber() (int32, error)
- func (pdb *ProtoDB) SaveEntity(e *pb.Entity) error
- func (pdb *ProtoDB) SaveGroup(g *pb.Group) error
- func (pdb *ProtoDB) SearchEntities(r db.SearchRequest) ([]*pb.Entity, error)
- func (pdb *ProtoDB) SearchGroups(r db.SearchRequest) ([]*pb.Group, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
LoadEntity loads a single entity from the data_root given the ID associated with the entity.
func (*ProtoDB) LoadGroup ¶
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
NextEntityNumber computes and return the next entity number.
func (*ProtoDB) NextGroupNumber ¶ added in v0.0.12
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 ¶
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 ¶
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
SearchEntities returns a slice of entity given a searchrequest.
func (*ProtoDB) SearchGroups ¶ added in v0.0.12
SearchGroups returns a slice of entity given a searchrequest.