Documentation
¶
Index ¶
- func DeriveRunnerID() string
- type Backend
- type ClaimResult
- type FileLock
- type FileStateBackend
- func (f *FileStateBackend) AppendStepLog(_ context.Context, _, _, _ string) error
- func (f *FileStateBackend) ClaimJob(ctx context.Context, runID string, job model.PlanJob, _ string) (*ClaimResult, error)
- func (f *FileStateBackend) Close(_ context.Context) error
- func (f *FileStateBackend) Heartbeat(_ context.Context, _, _, _ string) (*HeartbeatResult, error)
- func (f *FileStateBackend) InitRun(_ context.Context, plan *model.Plan, opts InitRunOptions) (*RunHandle, error)
- func (f *FileStateBackend) InitRunPlan(plan *model.Plan)
- func (f *FileStateBackend) LoadRunState(_ context.Context, runID string) (*state.ExecState, *state.ExecMetadata, error)
- func (f *FileStateBackend) ReadJobLog(_ context.Context, runID string, jobID string) (string, error)
- func (f *FileStateBackend) RunnableJobs(_ context.Context, runID string) ([]string, error)
- func (f *FileStateBackend) UpdateJob(ctx context.Context, runID, jobID, _ string, status JobStatus, errText string) error
- type HeartbeatResult
- type InitRunOptions
- type JobStatus
- type RemoteStateBackend
- func (r *RemoteStateBackend) AppendStepLog(ctx context.Context, runID string, jobID string, content string) error
- func (r *RemoteStateBackend) ClaimJob(ctx context.Context, runID string, job model.PlanJob, runnerID string) (*ClaimResult, error)
- func (r *RemoteStateBackend) Close(_ context.Context) error
- func (r *RemoteStateBackend) Heartbeat(ctx context.Context, runID string, jobID string, runnerID string) (*HeartbeatResult, error)
- func (r *RemoteStateBackend) InitRun(ctx context.Context, plan *model.Plan, opts InitRunOptions) (*RunHandle, error)
- func (r *RemoteStateBackend) LoadRunState(ctx context.Context, runID string) (*state.ExecState, *state.ExecMetadata, error)
- func (r *RemoteStateBackend) ReadJobLog(ctx context.Context, runID string, jobID string) (string, error)
- func (r *RemoteStateBackend) RunnableJobs(ctx context.Context, runID string) ([]string, error)
- func (r *RemoteStateBackend) UpdateJob(ctx context.Context, runID string, jobID string, runnerID string, ...) error
- type RunHandle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeriveRunnerID ¶
func DeriveRunnerID() string
DeriveRunnerID builds a stable runner identifier from the environment. In GitHub Actions it includes the GITHUB_JOB and GITHUB_RUN_ID so that concurrent matrix jobs have distinct identifiers.
Types ¶
type Backend ¶
type Backend interface {
// InitRun creates or joins a run for the given plan. Returns the run handle.
InitRun(ctx context.Context, plan *model.Plan, opts InitRunOptions) (*RunHandle, error)
// ClaimJob attempts to claim a job for this runner. The caller must inspect
// ClaimResult to decide whether to execute, wait, or exit.
ClaimJob(ctx context.Context, runID string, job model.PlanJob, runnerID string) (*ClaimResult, error)
// Heartbeat signals that the runner is still alive for the given job.
Heartbeat(ctx context.Context, runID string, jobID string, runnerID string) (*HeartbeatResult, error)
// UpdateJob sends the terminal status for a job.
UpdateJob(ctx context.Context, runID string, jobID string, runnerID string, status JobStatus, errText string) error
// AppendStepLog appends step output to the job-level log.
AppendStepLog(ctx context.Context, runID string, jobID string, content string) error
// RunnableJobs returns the list of job IDs that are currently runnable for the given run.
RunnableJobs(ctx context.Context, runID string) ([]string, error)
// LoadRunState reads run state for display (status/logs commands).
LoadRunState(ctx context.Context, runID string) (*state.ExecState, *state.ExecMetadata, error)
// ReadJobLog retrieves the combined log for a job.
ReadJobLog(ctx context.Context, runID string, jobID string) (string, error)
// Close releases any resources held by the backend.
Close(ctx context.Context) error
}
Backend is the state backend seam. Local filesystem state and remote HTTP state each implement this interface so the runner and commands can use either without embedding transport details.
type ClaimResult ¶
type ClaimResult struct {
Claimed bool
Takeover bool
CurrentStatus string // backend job status when not claimed
DepsWaiting bool
DepsBlocked bool
}
ClaimResult describes the outcome of a ClaimJob call.
type FileLock ¶ added in v1.12.1
type FileLock struct {
// contains filtered or unexported fields
}
FileLock provides cross-process mutual exclusion using advisory file locks. The lock file is created if it does not exist. On Unix systems, the lock is automatically released when the process exits (even on crash).
func NewFileLock ¶ added in v1.12.1
NewFileLock returns a lock bound to the given path. The lock is not acquired until Lock or TryLock is called.
func (*FileLock) Lock ¶ added in v1.12.1
Lock acquires an exclusive lock, blocking until the lock is available or ctx is cancelled. Returns a context error on timeout/cancellation.
type FileStateBackend ¶
FileStateBackend implements Backend using the local .orun/ filesystem store. When InitRun is called with a plan, the backend provides real cross-process claim semantics using advisory file locks scoped to the execution ID.
func NewFileStateBackend ¶
func NewFileStateBackend(store *state.Store) *FileStateBackend
NewFileStateBackend wraps an existing state.Store.
func (*FileStateBackend) AppendStepLog ¶
func (f *FileStateBackend) AppendStepLog(_ context.Context, _, _, _ string) error
AppendStepLog is a no-op locally — the runner writes logs via writeStepLog.
func (*FileStateBackend) ClaimJob ¶
func (f *FileStateBackend) ClaimJob(ctx context.Context, runID string, job model.PlanJob, _ string) (*ClaimResult, error)
ClaimJob acquires an execution-scoped file lock, checks the current state, and atomically marks the job as running if it can be claimed.
func (*FileStateBackend) Heartbeat ¶
func (f *FileStateBackend) Heartbeat(_ context.Context, _, _, _ string) (*HeartbeatResult, error)
Heartbeat is a no-op locally.
func (*FileStateBackend) InitRun ¶
func (f *FileStateBackend) InitRun(_ context.Context, plan *model.Plan, opts InitRunOptions) (*RunHandle, error)
func (*FileStateBackend) InitRunPlan ¶ added in v1.12.1
func (f *FileStateBackend) InitRunPlan(plan *model.Plan)
InitRunPlan stores the plan for dependency checking without creating execution directories. Use this when the runner creates the execution directory separately via Store.CreateExecution.
func (*FileStateBackend) LoadRunState ¶
func (f *FileStateBackend) LoadRunState(_ context.Context, runID string) (*state.ExecState, *state.ExecMetadata, error)
func (*FileStateBackend) ReadJobLog ¶
func (f *FileStateBackend) ReadJobLog(_ context.Context, runID string, jobID string) (string, error)
ReadJobLog concatenates all per-step log files for the given job.
func (*FileStateBackend) RunnableJobs ¶
RunnableJobs returns job IDs whose dependencies are all completed.
type HeartbeatResult ¶
type HeartbeatResult struct {
OK bool
}
HeartbeatResult is returned by Heartbeat.
type InitRunOptions ¶
type InitRunOptions struct {
RunID string
NamespaceID string
RepoFullName string
DryRun bool
Actor string
TriggerType string
}
InitRunOptions carries options for InitRun.
type RemoteStateBackend ¶
type RemoteStateBackend struct {
// contains filtered or unexported fields
}
RemoteStateBackend implements Backend using the orun-backend HTTP API.
func NewRemoteStateBackend ¶
func NewRemoteStateBackend(client *remotestate.Client, runnerID string) *RemoteStateBackend
NewRemoteStateBackend creates a RemoteStateBackend with the given HTTP client and runner identifier. runnerID should be unique per runner instance.
func (*RemoteStateBackend) AppendStepLog ¶
func (*RemoteStateBackend) ClaimJob ¶
func (r *RemoteStateBackend) ClaimJob(ctx context.Context, runID string, job model.PlanJob, runnerID string) (*ClaimResult, error)
func (*RemoteStateBackend) Heartbeat ¶
func (r *RemoteStateBackend) Heartbeat(ctx context.Context, runID string, jobID string, runnerID string) (*HeartbeatResult, error)
func (*RemoteStateBackend) InitRun ¶
func (r *RemoteStateBackend) InitRun(ctx context.Context, plan *model.Plan, opts InitRunOptions) (*RunHandle, error)
func (*RemoteStateBackend) LoadRunState ¶
func (r *RemoteStateBackend) LoadRunState(ctx context.Context, runID string) (*state.ExecState, *state.ExecMetadata, error)