util

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package util handles synthetic functions that aren't implemented natively on a datastore. These functions are almost by definition slower than if the datastore implemented an intelligent version natively, but they save work and test complexity in the simpler datastores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadEntityBatch

func LoadEntityBatch(ids []string, l loadEntityFunc) ([]*pb.Entity, error)

LoadEntityBatch uses the specified loader to load a batch of entities as specified by the provided slice of IDs. any failure in the loading of an entity will abort the entire load.

func LoadGroupBatch

func LoadGroupBatch(ids []string, l loadGroupFunc) ([]*pb.Group, error)

LoadGroupBatch functions identically to LoadEntityBatch, with apropriate substitutions made for groups.

func NextEntityNumber

func NextEntityNumber(l loadEntityFunc, ids entityIDsFunc) (int32, error)

NextEntityNumber computes and returns the next unnassigned number in the entity space.

func NextGroupNumber

func NextGroupNumber(lf loadGroupFunc, names groupNamesFunc) (int32, error)

NextGroupNumber computes the enxt available group number and returns it.

Types

type SearchIndex

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

SearchIndex holds the methods to search entities and groups with blevesearch. This is meant to be embedded into a db implementation to transparently give it the search functions.

func NewIndex

func NewIndex() *SearchIndex

NewIndex returns a new SearchIndex with the mappings configured and ready to use. Mappings are statically defined for simplicity, and in general new mappings shouldn't be added without a very good reason.

func (*SearchIndex) ConfigureCallback added in v0.1.0

func (s *SearchIndex) ConfigureCallback(el loadEntityFunc, gl loadGroupFunc)

ConfigureCallback is used to set the references to the loaders which are later used by the callback to fetch entities and groups for indexing.

func (*SearchIndex) DeleteEntity

func (s *SearchIndex) DeleteEntity(e *pb.Entity) error

DeleteEntity removes an entity from the index

func (*SearchIndex) DeleteGroup

func (s *SearchIndex) DeleteGroup(g *pb.Group) error

DeleteGroup removes a group from the index.

func (*SearchIndex) IndexCallback added in v0.1.0

func (s *SearchIndex) IndexCallback(e db.Event)

IndexCallback is meant to be plugged into the event system and is subsequently capable of maintaining the index based on events being fired during save and as files change on disk.

func (*SearchIndex) IndexEntity

func (s *SearchIndex) IndexEntity(e *pb.Entity) error

IndexEntity adds or updates an entity in the index.

func (*SearchIndex) IndexGroup

func (s *SearchIndex) IndexGroup(g *pb.Group) error

IndexGroup adds or updates a group in the index.

func (*SearchIndex) SearchEntities

func (s *SearchIndex) SearchEntities(r db.SearchRequest) ([]string, error)

SearchEntities searches the index for entities matching the qualities specified in the request.

func (*SearchIndex) SearchGroups

func (s *SearchIndex) SearchGroups(r db.SearchRequest) ([]string, error)

SearchGroups searches the index for groups matching the qualities specified in the request.

Jump to

Keyboard shortcuts

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