worker

package
v0.58.10 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 8 Imported by: 0

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

func SyncOnce(ctx context.Context, opts Options) error

SyncOnce runs one tick: drain one dirty batch, then a bounded backfill step. No connection or transaction is held across host callbacks or sink calls: each write is a short transaction fenced by the dirty-queue revision, so overlapping ticks are safe (only duplicated work) and a stale build never overwrites a newer one. Sink calls run after the document commits and before its row is acknowledged.

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. The worker records invalid documents individually; return an error only 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 is released before every host callback, so one connection
	// suffices. 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.

Jump to

Keyboard shortcuts

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