impl

package
v0.7.0-rc.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterBackend

func RegisterBackend(t rmtypes.ResourceProvisionType, f backendFactory)

RegisterBackend registers a factory for a provisioner type; last writer wins.

func RegisterPlanningPolicy

func RegisterPlanningPolicy[T utils.PriorityQueueItem](pt rmtypes.ResourceProvisionType, t PlanningPolicyType, f Factory[T])

Register adds a policy factory. Intended to be called from a policy package's init(); last writer wins.

Types

type Factory

type Factory[T utils.PriorityQueueItem] func(cfg PolicyConfig) (PlanningPolicy[T], error)

Factory constructs a PlanningPolicy. Policies self-register their factory from init(); last writer wins.

func LookupPlanningPolicy

Lookup retrieves a policy factory by type.

type Planner

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

Planner is an asynchronous implementation of plannerapi.Planner. Enqueue records the job in memory, returns a placeholder batch in "pending" status, and lets workers run Provision, wait for the resource to reach Running, then CreateBatch.

func NewPlanner

func NewPlanner(cfg PlannerConfig) *Planner

NewPlanner constructs a Planner with the given configuration. A nil Store disables persistence (used by tests).

func (*Planner) Cancel

func (q *Planner) Cancel(ctx context.Context, jobID string) (*plannerapi.Job, error)

Cancel enqueues a cancel request for async processing. It returns immediately with the cancelling job state.

func (*Planner) Close

func (q *Planner) Close() error

Close cancels in-flight work and waits for all workers to exit.

func (*Planner) Enqueue

func (q *Planner) Enqueue(ctx context.Context, req *plannerapi.EnqueueRequest) (*plannerapi.Job, error)

Enqueue records the job, pushes it onto the queue, and returns a placeholder batch in "pending" status.

func (*Planner) GetJob

func (q *Planner) GetJob(ctx context.Context, jobID string) (*plannerapi.Job, error)

GetJob resolves the JobID.

func (*Planner) ListJobs

ListJobs lists all jobs from the store with cursor-based pagination.

func (*Planner) Recover

func (q *Planner) Recover(ctx context.Context) error

Recover replays non-terminal jobs from the store into the Planner's in-memory state. Must be called once at startup, after NewPlanner and before the gRPC server begins accepting requests. Safe to call with a nil store (no-op).

Recover is supposed to be invoked once at startup. No locks are held.

func (*Planner) Start

func (q *Planner) Start(ctx context.Context) error

type PlannerConfig

type PlannerConfig struct {
	BatchClient            plannerclient.BatchClient
	Provisioner            provisioner.Provisioner
	Store                  store.Store
	PolicyType             PlanningPolicyType
	WorkerCount            int           // concurrent job processing, default 10
	PlanningInterval       time.Duration // planning loop interval, default 60s
	MaxConcurrentProvision int           // max concurrent provisioning jobs, default 1
}

PlannerConfig holds configuration for creating a Planner.

func DefaultPlannerConfig

func DefaultPlannerConfig() PlannerConfig

DefaultPlannerConfig returns a PlannerConfig with default values.

type PlanningInput

type PlanningInput[T utils.PriorityQueueItem] struct {
	PlannerBackend plannerBackend
	RunningQueue   utils.PriorityQueue[T]
	PendingQueue   utils.PriorityQueue[T]
}

PlanningInput includes the input parameters for the planning policy.

type PlanningPolicy

type PlanningPolicy[T utils.PriorityQueueItem] interface {
	Type() PlanningPolicyType
	Plan(ctx context.Context, input PlanningInput[T]) error
}

PlanningPolicy is the plugin interface for making scheduling decisions.

type PlanningPolicyType

type PlanningPolicyType string
const (
	PlanningPolicyTypeSimple PlanningPolicyType = "simple"
)

type PolicyConfig

type PolicyConfig struct {
	// MaxConcurrentProvisioning is the maximum number of jobs that can be
	// in the ResourcePreparing state simultaneously. Default is 1.
	MaxConcurrentProvisioning int
}

PolicyConfig holds configuration for planning policies.

func DefaultPolicyConfig

func DefaultPolicyConfig() PolicyConfig

DefaultPolicyConfig returns a PolicyConfig with default values.

type SimplePolicy

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

SimplePolicy is a simple policy that advances pending jobs.

func (*SimplePolicy) Plan

func (p *SimplePolicy) Plan(ctx context.Context, input PlanningInput[*queuedJob]) error

func (*SimplePolicy) Type

func (p *SimplePolicy) Type() PlanningPolicyType

Jump to

Keyboard shortcuts

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