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 ¶
This section is empty.
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)
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.
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
}
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"`
}
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"`
}
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.