queueintent

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LegacySchemaVersion   = 1
	PreviousSchemaVersion = 3
	SchemaVersion         = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Intent

type Intent struct {
	Key             string `json:"key"`
	ScaleSetID      int64  `json:"scale_set_id"`
	JobID           string `json:"job_id"`
	RunnerRequestID int64  `json:"runner_request_id"`
	WorkflowRunID   int64  `json:"workflow_run_id,omitempty"`
	JobDisplayName  string `json:"job_display_name,omitempty"`
	GitHubRunnerID  int64  `json:"github_runner_id,omitempty"`
	ScaleSetName    string `json:"scale_set_name"`
	RunnerName      string `json:"runner_name,omitempty"`
	// Owner is the forge account the scale set hangs from, written by GARM.
	// GitHub scopes a scale set name to one entity, so the name alone stopped
	// being an identity when the fleet gained a second tenant. Empty reads as
	// the fleet's own account, which is what every journal written before this
	// field existed meant.
	//
	// This is the journal's own vocabulary, not the tenant registry's: GARM
	// knows the account it serves and has no reason to know the registry ID
	// the fleet files it under. Translating one into the other is the
	// provider's job, at the one place that compares them.
	Owner          string    `json:"owner,omitempty"`
	Repository     string    `json:"repository"`
	WorkflowRef    string    `json:"workflow_ref"`
	EventName      string    `json:"event_name"`
	QueueTime      time.Time `json:"queue_time"`
	State          State     `json:"state"`
	Priority       int       `json:"priority"`
	StateEnteredAt time.Time `json:"state_entered_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	ExpiresAt      time.Time `json:"expires_at"`
}

Intent is the durable queue identity observed at JobAssigned before GARM changes desired capacity. RunnerRequestID is bound later at JobAvailable. GARM is the sole writer; provider and observer processes consume immutable fsync+rename generations without taking the writer lock.

func (Intent) OwnerAccount

func (i Intent) OwnerAccount() string

OwnerAccount resolves the intent's forge account, defaulting to the fleet's own so a journal written before the field existed keeps its original meaning.

type Journal

type Journal struct {
	SchemaVersion int                        `json:"schema_version"`
	Generation    uint64                     `json:"generation"`
	UpdatedAt     time.Time                  `json:"updated_at"`
	Intents       map[string]Intent          `json:"intents"`
	Repositories  map[string]RepositoryState `json:"repositories"`
}

func (Journal) Validate

func (j Journal) Validate() error

type Reader

type Reader struct {
	Path string
	Now  func() time.Time
}

func (Reader) ActiveForScaleSet

func (r Reader) ActiveForScaleSet(ctx context.Context, owner, scaleSet string) (bool, error)

ActiveForScaleSet reports whether the named scale set of the named tenant holds an intent that has passed central admission. Both halves are required: two tenants may serve the same scale set class name, and answering from the name alone would let one tenant's admitted job authorize the other's create.

func (Reader) HasActive

func (r Reader) HasActive(ctx context.Context) (bool, error)

func (Reader) ReadActive

func (r Reader) ReadActive(ctx context.Context) (Snapshot, error)

func (Reader) RepositoryForScaleSet

func (r Reader) RepositoryForScaleSet(ctx context.Context, owner, scaleSet string) (string, error)

RepositoryForScaleSet returns the one concrete repository carried by an admitted intent. Organization entities give providers only the account URL, so the durable pre-AcquireJobs journal is the authoritative narrowing point.

type RecoveryResult

type RecoveryResult struct {
	Applied            bool      `json:"applied"`
	Key                string    `json:"key"`
	ExpectedUpdatedAt  time.Time `json:"expected_updated_at"`
	PreviousGeneration uint64    `json:"previous_generation"`
	Generation         uint64    `json:"generation"`
	RecoveredAt        time.Time `json:"recovered_at"`
}

func RecoverCanceledUnbound

func RecoverCanceledUnbound(ctx context.Context, journalPath, lockPath, key string, expectedUpdatedAt time.Time, apply bool) (RecoveryResult, error)

RecoverCanceledUnbound removes one exact queued or assigned intent after the operator has proved its GitHub run/job is completed with conclusion cancelled. The intent must never have crossed the JobAvailable boundary.

func RecoverUnboundRunning

func RecoverUnboundRunning(ctx context.Context, journalPath, lockPath, key string, expectedUpdatedAt time.Time, apply bool) (RecoveryResult, error)

RecoverUnboundRunning removes one exact stale organization intent while GARM is stopped. It uses GARM's sibling lock and an identity-checked atomic rename; callers must separately prove that no provider lease exists.

type RepositoryState

type RepositoryState struct {
	Repository string `json:"repository"`
	Weight     uint64 `json:"weight"`
	Pass       uint64 `json:"pass"`
}

type Snapshot

type Snapshot struct {
	Generation uint64
	Stored     int
	Expired    int
	Active     []Intent
}

type State

type State string
const (
	StateQueued    State = "queued"
	StateAcquiring State = "acquiring"
	StateAcquired  State = "acquired"
	StateAssigned  State = "assigned"
	StateRunning   State = "running"
)

Jump to

Keyboard shortcuts

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