Documentation
¶
Overview ¶
Package resindexapi is the admin REST surface for how managed resources are indexed for search (#2111): how many are under each policy, and a reclassification that applies the operator's resources.index rules to every resource no writer chose a policy for.
Index ¶
Constants ¶
const NoEmbedderReason = "" /* 140-byte string literal not displayed */
NoEmbedderReason is what the answers say on a deployment with no embedding provider.
Variables ¶
This section is empty.
Functions ¶
func Mount ¶
func Mount(mux *http.ServeMux, wrap func(http.Handler) http.Handler, db *sql.DB, resolver *indexpolicy.Resolver, embedder bool)
Mount registers the routes over the platform's database: the counts read from it, and a reclassification under the resolver whose owed jobs are enqueued on the platform's own queue table, which wakes the workers of whichever replica claims them. With no embedder (embedder false) no worker exists to run them, so the reclassification enqueues none (#2638).
Types ¶
type Config ¶
type Config struct {
// Store reads the counts. nil mounts nothing.
Store Store
Reclassifier Reclassifier
// Runs keeps the last reclassification for every replica. Required with
// a Reclassifier.
Runs Runs
// NoIndexReason, when set, is why a reclassification owes no index work
// on this deployment (#2638): with no embedder no worker runs the queue,
// so the reclassifier is given no producers and the answers say so.
NoIndexReason string
}
Config carries the store, the reclassifier and where its runs are kept.
type IndexState ¶
type IndexState struct {
Counts resourceindex.PolicyCounts `json:"counts"`
LastRun *Run `json:"last_run,omitempty"`
// NoIndexReason is why a reclassification queues no index work on this
// deployment, absent when it queues what it owes.
NoIndexReason string `json:"no_index_reason,omitempty"`
}
IndexState is what GET answers: the counts, and the last reclassification any replica ran, absent when none has run.
type PostgresRuns ¶
PostgresRuns is Runs over resource_reclassify_runs.
func (PostgresRuns) Begin ¶
Begin implements Runs. A run unfinished after an hour is taken to have stopped with its replica; the reclassifier's advisory lock still refuses a start while one truly runs.
func (PostgresRuns) Finish ¶
func (p PostgresRuns) Finish(ctx context.Context, res resourcereclass.ReclassifyResult, failure string) error
Finish implements Runs.
type Reclassifier ¶
type Reclassifier interface {
Run(ctx context.Context) (resourcereclass.ReclassifyResult, error)
}
Reclassifier applies the rules. *resourceindex.Reclassifier satisfies it.
type Run ¶
type Run struct {
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Result *resourcereclass.ReclassifyResult `json:"result,omitempty"`
Error string `json:"error,omitempty"`
// NoIndexReason is why the reclassification queues no index work, absent
// when it queues what it owes.
NoIndexReason string `json:"no_index_reason,omitempty"`
}
Run is a reclassification, as every replica reports it.
type Runs ¶
type Runs interface {
// Begin records a run starting and reports false when one is running.
Begin(ctx context.Context) (started time.Time, ok bool, err error)
// Finish records how the run ended.
Finish(ctx context.Context, res resourcereclass.ReclassifyResult, failure string) error
// Last reads the last run, nil when none has started.
Last(ctx context.Context) (*Run, error)
}
Runs keeps the last reclassification where every replica reads it, and refuses a second start while one runs.
type Store ¶
type Store interface {
Counts(ctx context.Context) (resourceindex.PolicyCounts, error)
}
Store reads the counts. *resourceindex.Store satisfies it.