Documentation
¶
Overview ¶
Package adminhandler implements the go-faster/fs admin API: instance info and runtime access-key management, backed by an auth.Manager.
Index ¶
- Variables
- func UIMiddleware() func(http.Handler) http.Handler
- type AdminAPI
- func (a *AdminAPI) ControlRebalance(ctx context.Context, req *adminapi.RebalanceControlRequest) (*adminapi.RebalanceStatus, error)
- func (a *AdminAPI) CreateAccessKey(_ context.Context, req *adminapi.CreateAccessKeyRequest) (*adminapi.CreatedAccessKey, error)
- func (a *AdminAPI) DeleteAccessKey(_ context.Context, params adminapi.DeleteAccessKeyParams) error
- func (a *AdminAPI) GetInfo(_ context.Context) (*adminapi.InstanceInfo, error)
- func (a *AdminAPI) GetRebalanceStatus(ctx context.Context) (*adminapi.RebalanceStatus, error)
- func (a *AdminAPI) ListAccessKeys(_ context.Context) (*adminapi.AccessKeyList, error)
- func (a *AdminAPI) NewError(_ context.Context, err error) *adminapi.ErrorStatusCode
- type BuildInfo
- type Options
- type RebalanceControl
- type RebalanceState
- type RebalanceStatus
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
NewAdminAPI builds an AdminAPI. It panics if no Manager is provided.
func (*AdminAPI) ControlRebalance ¶
func (a *AdminAPI) ControlRebalance(ctx context.Context, req *adminapi.RebalanceControlRequest) (*adminapi.RebalanceStatus, error)
ControlRebalance starts, pauses or resumes the rebalance runner.
func (*AdminAPI) CreateAccessKey ¶
func (a *AdminAPI) CreateAccessKey(_ context.Context, req *adminapi.CreateAccessKeyRequest) (*adminapi.CreatedAccessKey, error)
CreateAccessKey creates a runtime credential.
func (*AdminAPI) DeleteAccessKey ¶
DeleteAccessKey removes a runtime credential.
func (*AdminAPI) GetRebalanceStatus ¶
GetRebalanceStatus reports the node's rebalance runner state.
func (*AdminAPI) ListAccessKeys ¶
ListAccessKeys returns all credentials, secrets omitted.
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.