Documentation ¶
Index ¶
- func DefaultSearch(ctx context.Context, manager *initutil.Manager, parentsStr ...string) (<-chan *ResultReturn, error)
- func NewRdvpConstructorFromPeerInfo(pis ...peer.AddrInfo) func(*zap.Logger, host.Host) (Provider, error)
- func NewRdvpConstructorFromStr(addrs ...string) func(context.Context, *zap.Logger, host.Host) (Provider, error)
- type Configurator
- type Coordinator
- type Engine
- type Informator
- type Parser
- type Provider
- type ResultReturn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSearch ¶
Types ¶
type Configurator ¶
type Configurator func(*coordinatorConfig) error
Configurator is used to configure the search engine.
func CAddEngine ¶
func CAddEngine(engines ...interface{}) Configurator
CAddEngine will add engines to the Coordinator. It accept either instancied Engine or function returning an Engine. The function can have some params, in this case the provider logic will be used. The function must return an Engine and may return an error, if it returns an error it will be checked against nil and any non nil value will error.
func CAddParser ¶
func CAddParser(parsers ...interface{}) Configurator
CAddParser adds some parser to the coordinator. It accept either instancied Parser or function returning a Parser. The function can have some params, in this case the provider logic will be used. The function must return a Parser and may return an error, if it returns an error it will be checked against nil and any non nil value will error.
func CAddProvider ¶
func CAddProvider(provs ...interface{}) Configurator
CAddProvider will add providers to the config, from first to last. It accept either instancied Provider or function returning a Provider. The function can have some params, in this case the provider logic will be used. The function must return a Provider and may return an error, if it returns an error it will be checked against nil and any non nil value will error. The provider will be registered for each type only if the type is not yet registered.
func CMerge ¶
func CMerge(cfgs ...Configurator) Configurator
CMerge merges multiple configurator, from first to last.
type Coordinator ¶
type Coordinator interface { // Do execute a search with the currently available ressources. // The chan will be closed once finished. Do(context.Context, ...interface{}) <-chan *ResultReturn }
Coordinator executes searches
func NewCoordinator ¶
func NewCoordinator(ctx context.Context, cfgs ...Configurator) (Coordinator, error)
NewCoordinatorWithBootstrap createsb a new Coordinator.
type Engine ¶
type Engine interface { Informator // Search tries a search on the passed string. // // Search will be called in sync, if Search wants to fork it need to increment the waitGroup and // then set the field `decrement` in the ResultReturn to true (only set the last if you return multiple of them). // Or if the search was unsuccess full, decrement yourself. // You could also send a ResultReturn with a nil `Object` and decrement set (nil r.Object are just ignored). // // If you want to write to the channel you must do it concurently. Search(context.Context, *sync.WaitGroup, chan<- *ResultReturn, *ResultReturn) }
type Informator ¶
type Informator interface { Name() string // contains filtered or unexported methods }
type Parser ¶
type Parser interface { Informator // Parse tryes to decode string // Return nil if weren't success full, else reflection will be used to know how to continue search. Parse(*ResultReturn) *ResultReturn }
type Provider ¶
type Provider interface { Informator Available() []reflect.Type Make(reflect.Type) (reflect.Value, error) }
Provider can creates objects for the engines or other provider. Provider are only used at instanciation time.
func NewManagerFromManager ¶
type ResultReturn ¶
type ResultReturn struct { Object interface{} // The thing actually found. Finder Informator // Reference to the object used to found it. Previous *ResultReturn // Reference to the object with the search were triggered (is nil for parents). Decrement bool // If true the Coordinator knows the search were a forked one and is now finished. }
ResultReturn is a struct used to comunicate metadata.
func (*ResultReturn) String ¶
func (r *ResultReturn) String() string