Documentation
¶
Overview ¶
Package worker maintains one tenant's keyword documents: it drains the dirty queue, runs a bounded cursor backfill and delivers every published document to the optional DocumentSink.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SyncOnce ¶
SyncOnce runs one tick: drain the dirty queue, then a bounded backfill step. One writer per schema and tenant: a competing tick returns without work. Documents and queue acknowledgements share one Postgres transaction. Sink calls run before acknowledgement but own their external transactions.
Types ¶
type BuildKeywordDocuments ¶
type BuildKeywordDocuments func(ctx context.Context, tenant, contentKind, language string, refs []contentref.ContentRef) ([]search.KeywordDocument, error)
BuildKeywordDocuments returns the current keyword document of every requested reference that exists in the given language. A missing reference means the content no longer exists and deletes its document. Return an error for failed or incomplete reads; never a partial result.
type ListContentPage ¶
type ListContentPage func(ctx context.Context, tenant, contentKind, language, cursor string, limit int) (refs []contentref.ContentRef, nextCursor string, done bool, err error)
ListContentPage enumerates a tenant's content of one kind and language for backfill: one bounded page from an opaque cursor, done when exhausted.
type Options ¶
type Options struct {
// Pool needs at least two connections: SyncOnce reserves one transaction
// while read-only host callbacks may query through the pool. Required.
Pool *pgxpool.Pool
Schema string
Tenant string
// SupportedLanguages are the document languages backfill enumerates. Required.
SupportedLanguages []string
// ContentKinds are the kinds backfill enumerates. Dirty rows of any kind
// are built through BuildKeywordDocuments.
ContentKinds []string
// Required.
ListContent ListContentPage
BuildKeywordDocuments BuildKeywordDocuments
// Sink receives every published or deleted document (see search.DocumentSink).
Sink search.DocumentSink
// Batch sizing (defaults are conservative).
DirtyBatchSize int
BackfillPageSize int
// Upper bound on how much cursor backfill work to do per SyncOnce.
BackfillMaxPages int
}
Options configures one tenant's worker.