Documentation
¶
Index ¶
- type Batch
- type BatchOption
- func WithDeleteCallback(fn func(any) error) BatchOption
- func WithErrorHandler(fn func(error)) BatchOption
- func WithExpire(d time.Duration) BatchOption
- func WithFlushCallback(fn func() error) BatchOption
- func WithFlushCondition(fn func() bool) BatchOption
- func WithForceFlushCallback(fn func() error) BatchOption
- func WithInsertCallback(fn func(any) error) BatchOption
- type BatchOptions
- type FacetParser
- type IndexCodex
- type IndexIDProvider
- type Indexer
- type QueryOptionsProvider
- type StackBatchFlush
- type StackBatchOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
func NewStackBatch ¶
func NewStackBatch[T any](ctx context.Context, opts ...StackBatchOption[T]) Batch
NewStackBatch creates a batch that simply stacks incoming Inserts and send them as flush value when expiry or stack size is reached.
type BatchOption ¶
type BatchOption func(*BatchOptions)
func WithDeleteCallback ¶
func WithDeleteCallback(fn func(any) error) BatchOption
WithDeleteCallback is called on each delete
func WithErrorHandler ¶
func WithErrorHandler(fn func(error)) BatchOption
WithErrorHandler sets an error handler for internal errors happening
func WithExpire ¶
func WithExpire(d time.Duration) BatchOption
WithExpire is the maximum wait time before triggering flush This flush is not going through the FlushCondition check, it is always triggered
func WithFlushCallback ¶
func WithFlushCallback(fn func() error) BatchOption
WithFlushCallback is triggered at flush time
func WithFlushCondition ¶
func WithFlushCondition(fn func() bool) BatchOption
WithFlushCondition provides an arbitrary check before triggering flush
func WithForceFlushCallback ¶
func WithForceFlushCallback(fn func() error) BatchOption
WithForceFlushCallback forces a full flush
func WithInsertCallback ¶
func WithInsertCallback(fn func(any) error) BatchOption
WithInsertCallback is called on each insert
type BatchOptions ¶
type FacetParser ¶
type FacetParser interface { UnmarshalFacet(data interface{}, facets chan interface{}) FlushCustomFacets() []interface{} }
FacetParser adds additional capacities to IndexCodex for understanding search results Facets
type IndexCodex ¶
type IndexCodex interface { // Marshal prepares an document for storing in index Marshal(input interface{}) (interface{}, error) // Unmarshal decodes a document found in index Unmarshal(indexed interface{}) (interface{}, error) // BuildQuery prepares a query to be executed. It returns a request object and optionnaly an aggregationRequest object BuildQuery(query interface{}, offset, limit int32, sortFields string, sortDesc bool) (interface{}, interface{}, error) // GetModel reads initialization schema to be loaded GetModel(sc configx.Values) (interface{}, bool) }
IndexCodex is the coder/decoder used by an Indexer.
type IndexIDProvider ¶
type IndexIDProvider interface {
IndexID() string
}
IndexIDProvider provides a method to retrieve a document unique ID
type Indexer ¶
type Indexer interface { // InsertOne stores one document. Write operations may be batched underneath. InsertOne(ctx context.Context, data interface{}) error // DeleteOne deletes one document. It can only be used if documents are providing IDs. DeleteOne(ctx context.Context, data interface{}) error // DeleteMany deletes documents by a search query. DeleteMany(ctx context.Context, query interface{}) (int32, error) // FindMany sends a search query to indexer. A custom IndexCodex can be used to accumulate some information during results parsing. FindMany(ctx context.Context, query interface{}, offset, limit int32, sortFields string, sortDesc bool, customCodex IndexCodex) (chan interface{}, error) // SetCodex sets the IndexCodex to be used for marshalling/unmarshalling data. Can be locally overriden during FindMany requests. SetCodex(c IndexCodex) GetCodex() IndexCodex // Resync should clear the index and rewrite it from scratch. Used by bolt implementations for defragmentation. Resync(ctx context.Context, logger func(string)) error // Truncate should free some disk space. Used by bleve implementation in conjunction with rotationSize parameter. Truncate(ctx context.Context, max int64, logger func(string)) error // Stats returns statistics about current indexer Stats(ctx context.Context) map[string]interface{} // NewBatch creates a batch for inserts/deletes NewBatch(ctx context.Context, options ...BatchOption) (Batch, error) // Init the underlying model Init(ctx context.Context, conf configx.Values) error // Close closes the index connection Close(ctx context.Context) error // CloseAndDrop closes the index and remove all resources CloseAndDrop(ctx context.Context) error }
Indexer is a generic interface for storages supporting advanced search techniques
type QueryOptionsProvider ¶
type QueryOptionsProvider interface {
BuildQueryOptions(query interface{}, offset, limit int32, sortFields string, sortDesc bool) (interface{}, error)
}
QueryOptionsProvider adds additional capacities to IndexCodex for building search Query
type StackBatchFlush ¶
type StackBatchOption ¶
type StackBatchOption[T any] func(options *stackBatchOptions[T])
func WithStackExpire ¶
func WithStackExpire[T any](expire time.Duration) StackBatchOption[T]
func WithStackFlush ¶
func WithStackFlush[T any](cb StackBatchFlush[T]) StackBatchOption[T]
func WithStackSize ¶
func WithStackSize[T any](size int) StackBatchOption[T]