Documentation
¶
Overview ¶
Package plugins defines the plugin system for Weave. Plugins are notified of lifecycle events (collection created, ingest completed, retrieval started, etc.) and can react to them (logging, metrics, tracing, auditing and so on).
Each lifecycle hook is a separate interface so plugins opt in only to the events they care about.
Index ¶
- type CollectionCreated
- type CollectionDeleted
- type DocumentDeleted
- type Extension
- type IngestChunked
- type IngestCompleted
- type IngestEmbedded
- type IngestFailed
- type IngestStarted
- type Registry
- func (r *Registry) EmitCollectionCreated(ctx context.Context, col *collection.Collection)
- func (r *Registry) EmitCollectionDeleted(ctx context.Context, colID id.CollectionID)
- func (r *Registry) EmitDocumentDeleted(ctx context.Context, docID id.DocumentID)
- func (r *Registry) EmitIngestChunked(ctx context.Context, chunks []*chunk.Chunk)
- func (r *Registry) EmitIngestCompleted(ctx context.Context, colID id.CollectionID, docCount, chunkCount int, ...)
- func (r *Registry) EmitIngestEmbedded(ctx context.Context, chunks []*chunk.Chunk)
- func (r *Registry) EmitIngestFailed(ctx context.Context, colID id.CollectionID, ingestErr error)
- func (r *Registry) EmitIngestStarted(ctx context.Context, colID id.CollectionID, docs []*document.Document)
- func (r *Registry) EmitReindexCompleted(ctx context.Context, colID id.CollectionID, elapsed time.Duration)
- func (r *Registry) EmitReindexStarted(ctx context.Context, colID id.CollectionID)
- func (r *Registry) EmitRetrievalCompleted(ctx context.Context, colID id.CollectionID, resultCount int, ...)
- func (r *Registry) EmitRetrievalFailed(ctx context.Context, colID id.CollectionID, retrievalErr error)
- func (r *Registry) EmitRetrievalStarted(ctx context.Context, colID id.CollectionID, query string)
- func (r *Registry) EmitShutdown(ctx context.Context)
- func (r *Registry) Extensions() []Extension
- func (r *Registry) Register(e Extension)
- type ReindexCompleted
- type ReindexStarted
- type RetrievalCompleted
- type RetrievalFailed
- type RetrievalStarted
- type Shutdown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollectionCreated ¶
type CollectionCreated interface {
OnCollectionCreated(ctx context.Context, col *collection.Collection) error
}
CollectionCreated is called when a collection is created.
type CollectionDeleted ¶
type CollectionDeleted interface {
OnCollectionDeleted(ctx context.Context, colID id.CollectionID) error
}
CollectionDeleted is called when a collection is deleted.
type DocumentDeleted ¶
type DocumentDeleted interface {
OnDocumentDeleted(ctx context.Context, docID id.DocumentID) error
}
DocumentDeleted is called when a document is deleted.
type Extension ¶
type Extension interface {
// Name returns a unique human-readable name for the extension.
Name() string
}
Extension is the base interface all Weave plugins must implement.
type IngestChunked ¶
IngestChunked is called after documents are chunked.
type IngestCompleted ¶
type IngestCompleted interface {
OnIngestCompleted(ctx context.Context, colID id.CollectionID, docCount, chunkCount int, elapsed time.Duration) error
}
IngestCompleted is called when ingestion finishes successfully.
type IngestEmbedded ¶
type IngestEmbedded interface {
OnIngestEmbedded(ctx context.Context, chunks []*chunk.Chunk) error
}
IngestEmbedded is called after chunks are embedded.
type IngestFailed ¶
type IngestFailed interface {
OnIngestFailed(ctx context.Context, colID id.CollectionID, err error) error
}
IngestFailed is called when ingestion fails.
type IngestStarted ¶
type IngestStarted interface {
OnIngestStarted(ctx context.Context, colID id.CollectionID, docs []*document.Document) error
}
IngestStarted is called when document ingestion begins.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds registered plugins and dispatches lifecycle events to them. It type-caches plugins at registration time so emit calls iterate only over plugins that implement the relevant hook.
func NewRegistry ¶
NewRegistry creates a plugin registry with the given logger.
func (*Registry) EmitCollectionCreated ¶
func (r *Registry) EmitCollectionCreated(ctx context.Context, col *collection.Collection)
EmitCollectionCreated notifies all plugins that implement CollectionCreated.
func (*Registry) EmitCollectionDeleted ¶
func (r *Registry) EmitCollectionDeleted(ctx context.Context, colID id.CollectionID)
EmitCollectionDeleted notifies all plugins that implement CollectionDeleted.
func (*Registry) EmitDocumentDeleted ¶
func (r *Registry) EmitDocumentDeleted(ctx context.Context, docID id.DocumentID)
EmitDocumentDeleted notifies all plugins that implement DocumentDeleted.
func (*Registry) EmitIngestChunked ¶
EmitIngestChunked notifies all plugins that implement IngestChunked.
func (*Registry) EmitIngestCompleted ¶
func (r *Registry) EmitIngestCompleted(ctx context.Context, colID id.CollectionID, docCount, chunkCount int, elapsed time.Duration)
EmitIngestCompleted notifies all plugins that implement IngestCompleted.
func (*Registry) EmitIngestEmbedded ¶
EmitIngestEmbedded notifies all plugins that implement IngestEmbedded.
func (*Registry) EmitIngestFailed ¶
EmitIngestFailed notifies all plugins that implement IngestFailed.
func (*Registry) EmitIngestStarted ¶
func (r *Registry) EmitIngestStarted(ctx context.Context, colID id.CollectionID, docs []*document.Document)
EmitIngestStarted notifies all plugins that implement IngestStarted.
func (*Registry) EmitReindexCompleted ¶
func (r *Registry) EmitReindexCompleted(ctx context.Context, colID id.CollectionID, elapsed time.Duration)
EmitReindexCompleted notifies all plugins that implement ReindexCompleted.
func (*Registry) EmitReindexStarted ¶
func (r *Registry) EmitReindexStarted(ctx context.Context, colID id.CollectionID)
EmitReindexStarted notifies all plugins that implement ReindexStarted.
func (*Registry) EmitRetrievalCompleted ¶
func (r *Registry) EmitRetrievalCompleted(ctx context.Context, colID id.CollectionID, resultCount int, elapsed time.Duration)
EmitRetrievalCompleted notifies all plugins that implement RetrievalCompleted.
func (*Registry) EmitRetrievalFailed ¶
func (r *Registry) EmitRetrievalFailed(ctx context.Context, colID id.CollectionID, retrievalErr error)
EmitRetrievalFailed notifies all plugins that implement RetrievalFailed.
func (*Registry) EmitRetrievalStarted ¶
EmitRetrievalStarted notifies all plugins that implement RetrievalStarted.
func (*Registry) EmitShutdown ¶
EmitShutdown notifies all plugins that implement Shutdown.
func (*Registry) Extensions ¶
Extensions returns all registered plugins.
type ReindexCompleted ¶
type ReindexCompleted interface {
OnReindexCompleted(ctx context.Context, colID id.CollectionID, elapsed time.Duration) error
}
ReindexCompleted is called when a collection reindex finishes.
type ReindexStarted ¶
type ReindexStarted interface {
OnReindexStarted(ctx context.Context, colID id.CollectionID) error
}
ReindexStarted is called when a collection reindex begins.
type RetrievalCompleted ¶
type RetrievalCompleted interface {
OnRetrievalCompleted(ctx context.Context, colID id.CollectionID, resultCount int, elapsed time.Duration) error
}
RetrievalCompleted is called when retrieval finishes successfully.
type RetrievalFailed ¶
type RetrievalFailed interface {
OnRetrievalFailed(ctx context.Context, colID id.CollectionID, err error) error
}
RetrievalFailed is called when retrieval fails.
type RetrievalStarted ¶
type RetrievalStarted interface {
OnRetrievalStarted(ctx context.Context, colID id.CollectionID, query string) error
}
RetrievalStarted is called when a retrieval query begins.