mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
feat: add prebuilds metrics collector (#17547)
Closes https://github.com/coder/internal/issues/509 --------- Signed-off-by: Danny Kopping <dannykopping@gmail.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
)
|
||||
|
||||
var ErrNoClaimablePrebuiltWorkspaces = xerrors.New("no claimable prebuilt workspaces found")
|
||||
@@ -25,12 +27,23 @@ type ReconciliationOrchestrator interface {
|
||||
}
|
||||
|
||||
type Reconciler interface {
|
||||
StateSnapshotter
|
||||
|
||||
// ReconcileAll orchestrates the reconciliation of all prebuilds across all templates.
|
||||
// It takes a global snapshot of the system state and then reconciles each preset
|
||||
// in parallel, creating or deleting prebuilds as needed to reach their desired states.
|
||||
ReconcileAll(ctx context.Context) error
|
||||
}
|
||||
|
||||
// StateSnapshotter defines the operations necessary to capture workspace prebuilds state.
|
||||
type StateSnapshotter interface {
|
||||
// SnapshotState captures the current state of all prebuilds across templates.
|
||||
// It creates a global database snapshot that can be viewed as a collection of PresetSnapshots,
|
||||
// each representing the state of prebuilds for a specific preset.
|
||||
// MUST be called inside a repeatable-read transaction.
|
||||
SnapshotState(ctx context.Context, store database.Store) (*GlobalSnapshot, error)
|
||||
}
|
||||
|
||||
type Claimer interface {
|
||||
Claim(ctx context.Context, userID uuid.UUID, name string, presetID uuid.UUID) (*uuid.UUID, error)
|
||||
Initiator() uuid.UUID
|
||||
|
||||
Reference in New Issue
Block a user