Documentation
¶
Overview ¶
Package jobhost owns complete-job admission, execution and durable control.
Index ¶
- Variables
- func CoreCapabilities() jobcontract.RunnerCapabilities
- type Acceptance
- type Change
- type Clock
- type Core
- type CoreDependencies
- type CoreRepository
- type Dependencies
- type EventPage
- type Execution
- type Executor
- type Guard
- type Host
- func (host *Host) ApplyCommand(ctx context.Context, command jobcontract.Command) (jobcontract.CommandConfirmation, bool, error)
- func (host *Host) Close() error
- func (*Host) GoString() string
- func (host *Host) Identity() Identity
- func (host *Host) MarkUnavailable()
- func (host *Host) Status() Status
- func (*Host) String() string
- func (host *Host) Submit(ctx context.Context, submission *jobcontract.Submission) (jobcontract.Snapshot, bool, error)
- type Identity
- type JobListQuery
- type JobPage
- type LocalIdentity
- type Maintenance
- type MaintenanceResult
- type MaintenanceStore
- type Outcome
- type PerformanceArchiveDocument
- type PerformanceExecutionRepository
- type PerformanceExecutor
- type PerformanceExecutorDependencies
- type PerformanceObservationWrite
- type PerformanceRepository
- type PerformanceResultDocument
- type Policy
- type Repository
- type RunExecutor
- type RunExecutorDependencies
- type RunReportDocument
- type RunRepository
- type Scheduling
- type Status
- type TaskConcurrencyStore
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("job_host_closed") ErrCapacity = errors.New("job_capacity_exceeded") ErrIdentity = errors.New("job_host_identity_mismatch") ErrCancelled = errors.New("job_cancelled") ErrLocalShutdown = errors.New("local_shutdown") ErrInterrupted = errors.New("runner_interrupted") ErrExecutionLimit = errors.New("job_execution_timeout") ErrMaintenance = errors.New("runner_maintenance") ErrSettlementLimit = errors.New("job_settlement_timeout") )
Functions ¶
func CoreCapabilities ¶
func CoreCapabilities() jobcontract.RunnerCapabilities
CoreCapabilities describes execution shared by local and remote hosts. Transport-specific management and file services add their own capabilities.
Types ¶
type Acceptance ¶
type Acceptance struct {
Spec jobcontract.JobSpec
Origin domain.ExecutionOrigin
SecretCommitment string
AcceptedAt time.Time
ContentClaims []jobcontent.Claim
}
Acceptance contains a keyed commitment, never task credential bytes.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core dispatches every current job kind to its existing execution component. Its owner must close JobHost before Core so owner interruption wins before execution resources are released.
func NewCore ¶
func NewCore(dependencies CoreDependencies) (*Core, error)
type CoreDependencies ¶
type CoreDependencies struct {
Repository CoreRepository
Runs runs.Executor
Transport http.RoundTripper
Clock Clock
ReportDiagnostic func(runs.Diagnostic)
}
type CoreRepository ¶
type CoreRepository interface {
RunRepository
PerformanceExecutionRepository
}
type Dependencies ¶
type Dependencies struct {
Repository Repository
Executor Executor
Guard Guard
Clock Clock
Policy Policy
Target jobcontract.ExecutionTarget
InstallationID string
EngineBuildID string
NodeID string
RunnerVersion string
CommitmentKey []byte
}
type EventPage ¶
type EventPage struct {
Events []jobcontract.Event `json:"events"`
LastSequence uint64 `json:"last_sequence"`
HasMore bool `json:"has_more"`
}
type Execution ¶
type Execution struct {
Spec jobcontract.JobSpec
Secrets map[string]*credentials.Lease
StopSending <-chan struct{}
OnProgress func(quicktest.PerformanceProgress)
// A known storage fault must make the owner unavailable before Core joins
// its workers. This callback must not wait for execution to finish.
OnPersistenceFailure func()
}
type Executor ¶
type Executor interface {
Execute(context.Context, Execution) (Outcome, error)
Settle(context.Context, jobcontract.JobSpec, Outcome) error
}
Execute must return only after requests, callbacks and Core workers stop. Settle seals remaining child facts and reports without sending requests. A non-nil error means execution facts could not be safely persisted.
type Guard ¶
Guard reserves verified assets, disk space and other admission resources. The reservation remains owned by the Host until all execution has stopped.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
func (*Host) ApplyCommand ¶
func (host *Host) ApplyCommand( ctx context.Context, command jobcontract.Command, ) (jobcontract.CommandConfirmation, bool, error)
func (*Host) Identity ¶
Identity returns non-secret admission identity and the current resource policy.
func (*Host) MarkUnavailable ¶
func (host *Host) MarkUnavailable()
MarkUnavailable isolates dispatch after the process detects a storage fault.
func (*Host) Submit ¶
func (host *Host) Submit(ctx context.Context, submission *jobcontract.Submission) (jobcontract.Snapshot, bool, error)
Submit consumes and clears the transport secret bytes on every path. Once accepted, neither request cancellation nor response loss owns the execution.
type Identity ¶
type Identity struct {
Target jobcontract.ExecutionTarget
InstallationID string
EngineBuildID string
Origin domain.ExecutionOrigin
Policy Policy
}
type JobListQuery ¶
type JobListQuery struct {
InstallationID string
Target jobcontract.ExecutionTarget
After uint64
Limit uint32
}
func (JobListQuery) Validate ¶
func (query JobListQuery) Validate() error
type JobPage ¶
type JobPage struct {
Contract int `json:"contract"`
Jobs []jobcontract.Snapshot `json:"jobs"`
NextCursor string `json:"next_cursor"`
HasMore bool `json:"has_more"`
}
type LocalIdentity ¶
LocalIdentity belongs to the desktop's operational database. The commitment key authenticates idempotent submissions; it is never a channel credential.
func (*LocalIdentity) Clear ¶
func (identity *LocalIdentity) Clear()
func (LocalIdentity) GoString ¶
func (LocalIdentity) GoString() string
func (LocalIdentity) MarshalJSON ¶
func (LocalIdentity) MarshalJSON() ([]byte, error)
func (LocalIdentity) String ¶
func (LocalIdentity) String() string
func (LocalIdentity) Validate ¶
func (identity LocalIdentity) Validate() error
type Maintenance ¶
type Maintenance struct {
// contains filtered or unexported fields
}
func NewMaintenance ¶
func NewMaintenance(ctx context.Context, host *Host, store MaintenanceStore) (*Maintenance, error)
func (*Maintenance) Apply ¶
func (maintenance *Maintenance) Apply( ctx context.Context, command jobcontract.MaintenanceCommand, ) (MaintenanceResult, error)
func (*Maintenance) Owns ¶
func (maintenance *Maintenance) Owns(host *Host) bool
type MaintenanceResult ¶
type MaintenanceResult struct {
Record jobcontract.MaintenanceRecord `json:"record"`
Status Status `json:"status"`
}
type MaintenanceStore ¶
type MaintenanceStore interface {
Read(context.Context) (*jobcontract.MaintenanceRecord, error)
Write(context.Context, jobcontract.MaintenanceRecord) error
// Sync establishes durability after an ambiguous write. Read visibility alone
// cannot confirm a failed rename-directory fsync.
Sync(context.Context) error
}
type PerformanceArchiveDocument ¶
type PerformanceArchiveDocument struct {
Report quicktest.PerformanceReport
Reference jobcontract.ReportReference
Document []byte
}
Statistical archive bytes are distinct from the complete execution result.
type PerformanceExecutionRepository ¶
type PerformanceExecutionRepository interface {
PerformanceRepository
quicktest.PerformanceArchive
GetJob(context.Context, string) (jobcontract.Snapshot, error)
GetJobSpec(context.Context, string) (jobcontract.JobSpec, error)
GetQuickPerformanceReport(context.Context, string) (quicktest.PerformanceReport, error)
}
type PerformanceExecutor ¶
type PerformanceExecutor struct {
// contains filtered or unexported fields
}
PerformanceExecutor runs only durably admitted Performance jobs. The JobHost owns dispatch, control and the winning terminal decision.
func NewPerformanceExecutor ¶
func NewPerformanceExecutor(dependencies PerformanceExecutorDependencies) (*PerformanceExecutor, error)
func (*PerformanceExecutor) Settle ¶
func (core *PerformanceExecutor) Settle(ctx context.Context, spec jobcontract.JobSpec, outcome Outcome) error
type PerformanceExecutorDependencies ¶
type PerformanceExecutorDependencies struct {
Repository PerformanceExecutionRepository
Transport http.RoundTripper
Clock Clock
}
type PerformanceRepository ¶
type PerformanceRepository interface {
RecordPerformanceObservation(context.Context, PerformanceObservationWrite) (jobcontract.PerformanceObservation, error)
GetPerformanceObservation(context.Context, string) (jobcontract.PerformanceObservation, error)
SealPerformanceResult(context.Context, string, time.Time) (PerformanceResultDocument, error)
ReadPerformanceResult(context.Context, string) (PerformanceResultDocument, error)
}
type PerformanceResultDocument ¶
type PerformanceResultDocument struct {
Result jobcontract.PerformanceResult
Reference jobcontract.PerformanceResultReference
Document []byte
}
Document is the stored canonical byte sequence. Its digest and download must use these bytes rather than re-encoding Result through another JSON writer.
type Policy ¶
type Policy struct {
MaxActiveJobs uint32 `json:"max_active_jobs"`
MaxQueuedJobs uint32 `json:"max_queued_jobs"`
MaxConcurrency uint32 `json:"max_concurrency"`
QueueTimeout time.Duration `json:"queue_timeout"`
ExecutionTimeout time.Duration `json:"execution_timeout"`
}
func RemotePolicy ¶
func RemotePolicy() Policy
type Repository ¶
type Repository interface {
AcceptJob(context.Context, Acceptance) (jobcontract.Snapshot, bool, error)
LookupJob(context.Context, Acceptance) (jobcontract.Snapshot, error)
GetJob(context.Context, string) (jobcontract.Snapshot, error)
GetJobSpec(context.Context, string) (jobcontract.JobSpec, error)
ChangeJob(context.Context, Change) (jobcontract.Snapshot, error)
ApplyJobCommand(context.Context, jobcontract.Command, time.Time) (jobcontract.CommandConfirmation, bool, error)
GetJobCommand(context.Context, string) (jobcontract.CommandConfirmation, error)
JobEvents(context.Context, string, uint64, uint32) (EventPage, error)
ActiveJobs(context.Context) ([]jobcontract.Snapshot, error)
RecoveryJobs(context.Context) ([]jobcontract.Snapshot, error)
RecordJobProgress(context.Context, string, quicktest.PerformanceProgress, time.Time) error
MarkJobSettled(context.Context, string) error
}
type RunExecutor ¶
type RunExecutor struct {
// contains filtered or unexported fields
}
RunExecutor executes Run and Comparison jobs through the existing Core. Performance jobs have their own execution and observation component.
func NewRunExecutor ¶
func NewRunExecutor(dependencies RunExecutorDependencies) (*RunExecutor, error)
func (*RunExecutor) Close ¶
func (core *RunExecutor) Close() error
Close follows JobHost.Close so it never reclassifies a remote interruption.
func (*RunExecutor) Settle ¶
func (core *RunExecutor) Settle(ctx context.Context, spec jobcontract.JobSpec, outcome Outcome) error
type RunExecutorDependencies ¶
type RunExecutorDependencies struct {
Repository RunRepository
Executor runs.Executor
Clock Clock
ReportDiagnostic func(runs.Diagnostic)
}
type RunReportDocument ¶
type RunReportDocument struct {
Report domain.Report
Reference jobcontract.ReportReference
Document []byte
}
type RunRepository ¶
type RunRepository interface {
runs.ExecutionRepository
comparisons.ExecutionRepository
reporting.ReportRepository
ListReportsForRuns(context.Context, []string) ([]domain.Report, error)
}
type Scheduling ¶
type Scheduling struct {
// contains filtered or unexported fields
}
func NewScheduling ¶
func NewScheduling(host *Host, store TaskConcurrencyStore) (*Scheduling, error)
func (*Scheduling) Apply ¶
func (scheduling *Scheduling) Apply(ctx context.Context, command jobcontract.TaskConcurrencyCommand) error
func (*Scheduling) Owns ¶
func (scheduling *Scheduling) Owns(host *Host) bool