Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache caches the result of a function.
func (*Cache) GetOrLoad ¶
func (c *Cache) GetOrLoad(key interface{}, loader CacheEntryLoader) (interface{}, error)
GetOrLoad tries to retrieve an existing element from the cache by an indexed `key` . If there is already an entry for (CacheEntry) the key, the cached content is returned. If there is not a cached value, then `loader` (CacheEntryLeader) is executed and its results are cached using the provided `key` as index.
type CacheEntry ¶
type CacheEntry struct {
// contains filtered or unexported fields
}
CacheEntry is the stored element in Cache.
type CacheEntryLoader ¶
type CacheEntryLoader func() (interface{}, error)
CacheEntryLoader is a function that caches the result of the first call of function.
type Document ¶
type Document interface{}
Document is an interface that represents a generic data structure.
type ExecutionContext ¶
type ExecutionContext struct {
Context context.Context
Request Request
Payload *Payload
// contains filtered or unexported fields
}
ExecutionContext is used during the filling process. It stores essential data structures to executing the enrichment processes.
func (*ExecutionContext) Cache ¶
func (e *ExecutionContext) Cache() *Cache
Cache instatiates a new Cache.
type Field ¶
type Field struct {
Name FieldName
Fill func(int, ExecutionContext) error
Clear func(Document)
}
Field represents a valid field. It has a name and functions for filling and cleaning itself.
type FieldProvider ¶
FieldProvider is able to load an existing set of []Document with certain fields. The `Provides()` returns a list of Field's, which in turn contains methods to filling and cleaning a Document.
type IndexProvider ¶
type IndexProvider interface {
Execute(ctx context.Context, request Request, fields []string) (*Payload, error)
Provides() []Index
}
IndexProvider is similar to FieldProvider in some aspects: it also provides specifically defined fields and encapsulates the mechanics of retrieving and populating them. However, the IndexProvider should not depend on anyone else, as FieldProvider does. Also, an IndexProvider has an additional responsibility: to create the initial base of documents (encapsulated inside Payload) to be enriched by the FieldProviders.
type Payload ¶
type Payload struct {
Documents []Document
CustomData interface{}
}
Payload stores the slice of documents and also supports an arbitrary data to be used when necessary.
type Plan ¶
Plan is the product of the QueryPlanner. It can be executed, returning a Payload with the enriched Document and CustomData.
type QueryPlanner ¶
QueryPlanner is an interface that creates a Plan.
func NewQueryPlanner ¶
func NewQueryPlanner(indexProvider IndexProvider, providers ...FieldProvider) (QueryPlanner, error)
NewQueryPlanner returns a new query planner unsing @providers.