Help us shape the future of Go! Take the 2026 Go Developer Survey

resindexapi

package
v1.149.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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.

func Register

func Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler, cfg Config)

Register mounts the routes, each behind wrap, the admin API's authentication.

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

type PostgresRuns struct{ DB *sql.DB }

PostgresRuns is Runs over resource_reclassify_runs.

func (PostgresRuns) Begin

func (p PostgresRuns) Begin(ctx context.Context) (time.Time, bool, error)

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

Finish implements Runs.

func (PostgresRuns) Last

func (p PostgresRuns) Last(ctx context.Context) (*Run, error)

Last 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.

Jump to

Keyboard shortcuts

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