adminhandler

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package adminhandler implements the go-faster/fs admin API: instance info and runtime access-key management, backed by an auth.Manager.

Index

Constants

This section is empty.

Variables

View Source
var ErrRebalanceConflict = errors.New("invalid rebalance transition")

ErrRebalanceConflict marks an invalid rebalance transition (starting a running rebalance, pausing an idle one); it maps to 409.

Functions

func UIMiddleware

func UIMiddleware() func(http.Handler) http.Handler

UIMiddleware serves the embedded admin SPA for non-API requests, delegating everything under /api/ to the next handler (the ogen server). Unknown paths fall back to index.html so client-side routing works. When the SPA was not built, a placeholder page is served instead.

Types

type AdminAPI

type AdminAPI struct {
	// contains filtered or unexported fields
}

AdminAPI implements adminapi.Handler.

func NewAdminAPI

func NewAdminAPI(opts Options) *AdminAPI

NewAdminAPI builds an AdminAPI. It panics if no Manager is provided.

func (*AdminAPI) ControlRebalance

ControlRebalance starts, pauses or resumes the rebalance runner.

func (*AdminAPI) CreateAccessKey

CreateAccessKey creates a runtime credential.

func (*AdminAPI) DeleteAccessKey

func (a *AdminAPI) DeleteAccessKey(_ context.Context, params adminapi.DeleteAccessKeyParams) error

DeleteAccessKey removes a runtime credential.

func (*AdminAPI) GetInfo

func (a *AdminAPI) GetInfo(_ context.Context) (*adminapi.InstanceInfo, error)

GetInfo returns build info and uptime.

func (*AdminAPI) GetRebalanceStatus

func (a *AdminAPI) GetRebalanceStatus(ctx context.Context) (*adminapi.RebalanceStatus, error)

GetRebalanceStatus reports the node's rebalance runner state.

func (*AdminAPI) ListAccessKeys

func (a *AdminAPI) ListAccessKeys(_ context.Context) (*adminapi.AccessKeyList, error)

ListAccessKeys returns all credentials, secrets omitted.

func (*AdminAPI) NewError

func (a *AdminAPI) NewError(_ context.Context, err error) *adminapi.ErrorStatusCode

NewError maps an unhandled error to a 500 structured response.

type BuildInfo

type BuildInfo struct {
	Version string
	Commit  string
}

BuildInfo is static build metadata reported by GetInfo.

type Options

type Options struct {
	// Manager is the access-key store to manage. Required.
	Manager *auth.Manager
	// Build is reported by GetInfo.
	Build BuildInfo
	// AuthEnabled reports whether the S3 server enforces SigV4.
	AuthEnabled bool
	// StartTime is the process start, for uptime. Defaults to now.
	StartTime time.Time
	// Rebalance drives the cluster rebalance runner; nil outside cluster mode
	// (the endpoints then report "disabled" / refuse control).
	Rebalance RebalanceControl
	// contains filtered or unexported fields
}

Options configures an AdminAPI.

type RebalanceControl

type RebalanceControl interface {
	// Start launches the rebalance (campaigning for the cluster-wide slot).
	// Returns ErrRebalanceConflict when one is already waiting or running.
	Start(ctx context.Context) error
	// Pause stops this node's runner, keeping the resume cursor. Returns
	// ErrRebalanceConflict when nothing is waiting or running.
	Pause(ctx context.Context) error
	// Resume relaunches a paused rebalance from the persisted cursor. Returns
	// ErrRebalanceConflict unless the runner is paused.
	Resume(ctx context.Context) error
	// Status snapshots the runner.
	Status(ctx context.Context) RebalanceStatus
}

RebalanceControl drives the node's cluster rebalance runner. Implemented by the cluster runtime; absent (nil) outside cluster mode.

type RebalanceState

type RebalanceState string

RebalanceState is the node-local runner state.

const (
	RebalanceIdle    RebalanceState = "idle"
	RebalanceWaiting RebalanceState = "waiting"
	RebalanceRunning RebalanceState = "running"
	RebalancePaused  RebalanceState = "paused"
	RebalanceDone    RebalanceState = "done"
	RebalanceFailed  RebalanceState = "failed"
)

Runner states; see the admin API schema for semantics.

type RebalanceStatus

type RebalanceStatus struct {
	State RebalanceState
	// Objects, Relocated and Failed are the current or last run's progress.
	Objects, Relocated, Failed int
	// CursorBucket/CursorKey is the persisted resume cursor (empty when none).
	CursorBucket, CursorKey string
	// StartedAt/FinishedAt frame the current or last run; zero when unset.
	StartedAt, FinishedAt time.Time
	// Err is why the last run failed.
	Err string
	// RepairQueueDepth is the node's pending async remainder backlog.
	RepairQueueDepth int
}

RebalanceStatus is a snapshot of the node's rebalance runner.

Jump to

Keyboard shortcuts

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