p42runtime

package
v1.0.64 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package p42runtime defines interfaces for job runtime providers. It enables the CLI to support multiple runtimes (Apple container, Podman) through a common abstraction.

Index

Constants

View Source
const (
	RuntimeApple  = "apple"
	RuntimePodman = "podman"
)

Variables

This section is empty.

Functions

func GetCompletedJobIDs

func GetCompletedJobIDs(ctx context.Context, provider Provider) ([]string, error)

GetCompletedJobIDs returns IDs of jobs that have log files but are no longer running. It computes this as: all job IDs with logs - running job IDs.

Types

type Job

type Job struct {
	TaskID      string
	TurnIndex   int
	Running     bool
	TaskTitle   string
	CreatedDate time.Time
}

Job represents a container job managed by a runtime.

func GetJobs

func GetJobs(ctx context.Context, provider Provider, client *p42.Client, tenantID string, verbose bool, includeCompleted bool) ([]*Job, error)

GetJobs returns a fully populated, sorted list of jobs. It performs the following steps: 1. Gets running job IDs from provider. 2. Optionally gets completed job IDs from provider. 3. Fetches job data from the API (TaskTitle, CreatedDate). 4. Sorts by CreatedDate (descending), TaskTitle, TaskID.

type JobOptions

type JobOptions struct {
	JobID      string
	Image      string
	CPUs       int // Required. Number of CPUs to allocate.
	MemoryInGB int // Required. Memory in whole gigabytes.
	Entrypoint string
	Args       []string
	Stdin      io.Reader
	Stdout     io.Writer
	Stderr     io.Writer
}

JobOptions specifies the configuration for running a job.

type Provider

type Provider interface {
	// Name returns the configuration name (e.g., "apple", "podman") of the provider.
	Name() string
	// IsInstalled reports whether the runtime is available on the system.
	IsInstalled() bool

	// PullImage pulls the specified container image.
	PullImage(ctx context.Context, image string) error

	// RunJob runs a job with the specified options.
	RunJob(ctx context.Context, opts JobOptions) error

	// KillJob terminates the job with the given ID.
	KillJob(ctx context.Context, jobID string) error

	// GetRunningJobIDs returns IDs of all running jobs managed by this runtime.
	GetRunningJobIDs(ctx context.Context) ([]string, error)
	// GetAllJobIDs returns IDs of all jobs with log files (both running and completed).
	GetAllJobIDs(ctx context.Context) ([]string, error)

	// ValidateJobID checks if the given job ID is valid for this runtime.
	ValidateJobID(jobID string) error

	// DeleteJobLog removes the log file for the specified job.
	DeleteJobLog(jobID string) error
}

Provider defines the interface for job runtime implementations. Each supported runtime (Apple container, Podman) must implement this interface.

Directories

Path Synopsis
Package apple implements the RuntimeProvider interface for Apple's container runtime.
Package apple implements the RuntimeProvider interface for Apple's container runtime.

Jump to

Keyboard shortcuts

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