plugins

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 8 Imported by: 0

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

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

type IngestChunked interface {
	OnIngestChunked(ctx context.Context, chunks []*chunk.Chunk) error
}

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

func NewRegistry(logger log.Logger) *Registry

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

func (r *Registry) EmitIngestChunked(ctx context.Context, chunks []*chunk.Chunk)

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

func (r *Registry) EmitIngestEmbedded(ctx context.Context, chunks []*chunk.Chunk)

EmitIngestEmbedded notifies all plugins that implement IngestEmbedded.

func (*Registry) EmitIngestFailed

func (r *Registry) EmitIngestFailed(ctx context.Context, colID id.CollectionID, ingestErr error)

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

func (r *Registry) EmitRetrievalStarted(ctx context.Context, colID id.CollectionID, query string)

EmitRetrievalStarted notifies all plugins that implement RetrievalStarted.

func (*Registry) EmitShutdown

func (r *Registry) EmitShutdown(ctx context.Context)

EmitShutdown notifies all plugins that implement Shutdown.

func (*Registry) Extensions

func (r *Registry) Extensions() []Extension

Extensions returns all registered plugins.

func (*Registry) Register

func (r *Registry) Register(e Extension)

Register adds a plugin and type-asserts it into all applicable hook caches. Plugins are notified in registration order.

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.

type Shutdown

type Shutdown interface {
	OnShutdown(ctx context.Context) error
}

Shutdown is called during graceful shutdown.

Jump to

Keyboard shortcuts

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