pool

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pool maintains N ephemeral runner slots per OS pool, re-provisioning each slot when its runner finishes its single job (the process-exit model).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hooks

type Hooks struct {
	OnStart func(pool string)
	OnStop  func(pool string, exitCode int, err error)
}

Hooks observe a runner's lifecycle (used for metrics). Either may be nil.

type Launcher

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

Launcher launches one ephemeral runner for a pool. It is the shared unit used by both the always-on pool model and the webhook autoscaler.

func NewLauncher

func NewLauncher(cfg config.Pool, image string, be backend.Backend, gh github.ClientProvider, env map[string]string, mounts []backend.Mount, logger *slog.Logger, hooks Hooks) *Launcher

NewLauncher builds a Launcher.

func (*Launcher) Allows

func (l *Launcher) Allows(job github.QueuedJob) bool

Allows reports whether this pool may register a runner for job.

func (*Launcher) EnsureImage

func (l *Launcher) EnsureImage(ctx context.Context) error

EnsureImage makes sure the runner image is present.

func (*Launcher) Labels

func (l *Launcher) Labels() []string

Labels are the runner labels for this pool.

func (*Launcher) Max

func (l *Launcher) Max() int

Max is the pool's max concurrent runners.

func (*Launcher) Name

func (l *Launcher) Name() string

Name is the pool name.

func (*Launcher) RequiresWorkflowMetadata

func (l *Launcher) RequiresWorkflowMetadata() bool

RequiresWorkflowMetadata reports whether this pool authorizes jobs using fields that are available only from the workflow-run record.

func (*Launcher) RunJob

func (l *Launcher) RunJob(ctx context.Context, job github.QueuedJob) (int, error)

RunJob provisions a fresh JIT runner for an authorized queued job.

func (*Launcher) RunOne

func (l *Launcher) RunOne(ctx context.Context) (int, error)

RunOne provisions a fresh JIT runner for warm-pool slot zero and blocks until it finishes its one job. This is the warm-capacity path: there is no queued job to place against. When a specific repo has queued work, call RunOneOn instead.

func (*Launcher) RunOneForSlot

func (l *Launcher) RunOneForSlot(ctx context.Context, slot int) (int, error)

RunOneForSlot provisions a fresh runner for a stable warm-pool slot.

func (*Launcher) RunOneOn

func (l *Launcher) RunOneOn(ctx context.Context, client *github.Client) (int, error)

RunOneOn provisions a fresh JIT runner registered to client's repo and blocks until it finishes its one job. A repo-scoped runner binds to exactly one repo, so demand-driven launches must pass the client for the repo that queued the job; otherwise the runner idles on a repo that has no work while the job that triggered the launch stays queued. A nil client is rejected.

type Manager

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

Manager runs multiple pools concurrently.

func NewManager

func NewManager(pools []*Pool, logger *slog.Logger) *Manager

NewManager builds a Manager.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

Run starts all pools and blocks until ctx is cancelled.

type Pool

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

Pool keeps a pool's slots filled with ephemeral runners.

func New

func New(cfg config.Pool, image string, be backend.Backend, gh github.ClientProvider, env map[string]string, mounts []backend.Mount, logger *slog.Logger) *Pool

New builds a Pool.

func NewPool

func NewPool(l *Launcher, logger *slog.Logger) *Pool

NewPool wraps an existing Launcher (shared with the autoscaler).

func NewWithHooks

func NewWithHooks(cfg config.Pool, image string, be backend.Backend, gh github.ClientProvider, env map[string]string, mounts []backend.Mount, logger *slog.Logger, hooks Hooks) *Pool

NewWithHooks builds a Pool with lifecycle hooks (metrics).

func (*Pool) Run

func (p *Pool) Run(ctx context.Context) error

Run ensures the image is present, then keeps all slots filled until ctx ends.

Jump to

Keyboard shortcuts

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