360 lines
8.1 KiB
Go
360 lines
8.1 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
type RunJobProgressReport struct {
|
|
Percent int
|
|
Message string
|
|
}
|
|
|
|
type RunJobAssignment struct {
|
|
JobID string
|
|
ServerInstanceID string
|
|
RunEndpointID string
|
|
Capability string
|
|
TargetKey string
|
|
InputRef string
|
|
IdempotencyKey string
|
|
State JobState
|
|
Progress RunJobProgressReport
|
|
ResultRef string
|
|
ExecutionInput JobExecutionInput
|
|
LeaseToken string
|
|
Attempt int
|
|
MaxAttempts int
|
|
AckDeadlineAt time.Time
|
|
LeaseExpiresAt time.Time
|
|
NextAttemptAt time.Time
|
|
ProgressSequence uint64
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type RunJobClaim struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
Capabilities []string
|
|
Capacity RunCapacity
|
|
}
|
|
|
|
type RunJobClaimResult struct {
|
|
Accepted bool
|
|
RunEndpointID string
|
|
HasJob bool
|
|
Job *RunJobAssignment
|
|
NextPollSeconds int
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type RunJobAck struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
Message string
|
|
}
|
|
|
|
type RunJobAckResult struct {
|
|
Accepted bool
|
|
Job RunJobAssignment
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type RunJobProgress struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
Progress RunJobProgressReport
|
|
Sequence uint64
|
|
}
|
|
|
|
type RunJobProgressResult struct {
|
|
Accepted bool
|
|
Job RunJobAssignment
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type RunJobResult struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
State JobState
|
|
Progress RunJobProgressReport
|
|
ResultRef string
|
|
Message string
|
|
ErrorCode string
|
|
Retryable bool
|
|
ExecutionResult JobExecutionResult
|
|
}
|
|
|
|
type RunJobResultResult struct {
|
|
Accepted bool
|
|
Job RunJobAssignment
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type DistributionBuildInputRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type DistributionBuildInput struct {
|
|
JobID string
|
|
ComponentKind DistributionComponentKind
|
|
ServerInstanceID string
|
|
PluginID string
|
|
RunEndpointID string
|
|
ProfileKey string
|
|
TargetOS string
|
|
TargetArch string
|
|
TargetRelease string
|
|
PackageFormat string
|
|
RepositoryURL string
|
|
SourceRevision string
|
|
ArtifactID string
|
|
OutputFilename string
|
|
SecretRef string
|
|
KeyGeneration int
|
|
AuthKey string
|
|
}
|
|
|
|
type DependencyExecutionInputRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type DependencyExecutionInput struct {
|
|
JobID string
|
|
ServerInstanceID string
|
|
RunEndpointID string
|
|
PluginID string
|
|
PluginVersion string
|
|
ProfileKey string
|
|
TargetOS string
|
|
TargetArch string
|
|
PlanDigest string
|
|
Probe RuntimeDependencyProbe
|
|
Plan RuntimeInstallPlan
|
|
Bindings map[string]string
|
|
}
|
|
|
|
type SourceRCONExecutionInputRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
// SourceRCONExecutionInput is sent only to the active signed Run lease. Its
|
|
// Command value must never be persisted in a Job, assignment, or journal.
|
|
type SourceRCONExecutionInput struct {
|
|
JobID string
|
|
ServerInstanceID string
|
|
RunEndpointID string
|
|
Command string
|
|
}
|
|
|
|
type RunUpdateInputRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type RunUpdateInput struct {
|
|
JobID string
|
|
ServerInstanceID string
|
|
RunEndpointID string
|
|
ArtifactID string
|
|
Checksum string
|
|
SizeBytes int64
|
|
TargetOS string
|
|
TargetArch string
|
|
PackageFormat string
|
|
ExecutableName string
|
|
TargetRelease string
|
|
ChunkSizeBytes int
|
|
}
|
|
|
|
type RunUpdateChunkRequest struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
Offset int64
|
|
Length int
|
|
}
|
|
|
|
type RunUpdateChunk struct {
|
|
JobID string
|
|
ArtifactID string
|
|
Offset int64
|
|
TotalBytes int64
|
|
Checksum string
|
|
Payload []byte
|
|
Complete bool
|
|
}
|
|
|
|
type RunUpdateHealthReport struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
Outcome string
|
|
Version string
|
|
}
|
|
|
|
type RunUpdateHealthResult struct {
|
|
Accepted bool
|
|
JobID string
|
|
Phase RunUpdatePhase
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type DependencyExecutionEvidence struct {
|
|
ProbeKey string `json:"probeKey"`
|
|
PlanKey string `json:"planKey,omitempty"`
|
|
PlanDigest string `json:"planDigest"`
|
|
State string `json:"state"`
|
|
Evidence string `json:"evidence,omitempty"`
|
|
CompletedSteps int `json:"completedSteps,omitempty"`
|
|
}
|
|
|
|
type RunUpdateExecutionEvidence struct {
|
|
TargetRelease string `json:"targetRelease"`
|
|
Phase string `json:"phase"`
|
|
}
|
|
|
|
type RunJobCancelRequest struct {
|
|
JobID string
|
|
Reason string
|
|
}
|
|
|
|
type RunJobCancelRequestResult struct {
|
|
Accepted bool
|
|
JobID string
|
|
Reason string
|
|
RequestedAt time.Time
|
|
CompletedAt time.Time
|
|
State JobState
|
|
}
|
|
|
|
type RunJobCancelPoll struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type RunJobCancelPollResult struct {
|
|
Accepted bool
|
|
RunEndpointID string
|
|
HasCancel bool
|
|
JobID string
|
|
Reason string
|
|
RequestedAt time.Time
|
|
ServerTime time.Time
|
|
}
|
|
|
|
type RunJobReconcileEntry struct {
|
|
JobID string
|
|
LeaseToken string
|
|
Attempt int
|
|
}
|
|
|
|
type RunJobReconcile struct {
|
|
RunEndpointID string
|
|
SessionToken string
|
|
ActiveJobs []RunJobReconcileEntry
|
|
}
|
|
|
|
type RunJobReconcileResult struct {
|
|
Accepted bool
|
|
RunEndpointID string
|
|
ConfirmedJobs []RunJobAssignment
|
|
DiscardJobIDs []string
|
|
ServerTime time.Time
|
|
}
|
|
|
|
func CopyRunJobAssignment(assignment RunJobAssignment) RunJobAssignment {
|
|
assignment.ExecutionInput.Inputs = CopyStringMap(assignment.ExecutionInput.Inputs)
|
|
assignment.ExecutionInput.DLLExtensions = append([]RuntimeDLLExtensionPlan(nil), assignment.ExecutionInput.DLLExtensions...)
|
|
assignment.ExecutionInput.SourceRCON = CopyRuntimeSourceRCONPlan(assignment.ExecutionInput.SourceRCON)
|
|
return assignment
|
|
}
|
|
|
|
func CopyRunJobAssignmentPtr(assignment *RunJobAssignment) *RunJobAssignment {
|
|
if assignment == nil {
|
|
return nil
|
|
}
|
|
copy := CopyRunJobAssignment(*assignment)
|
|
return ©
|
|
}
|
|
|
|
func CopyRunJobClaim(claim RunJobClaim) RunJobClaim {
|
|
claim.Capabilities = CopyStringSlice(claim.Capabilities)
|
|
return claim
|
|
}
|
|
|
|
func CopyRunJobClaimResult(result RunJobClaimResult) RunJobClaimResult {
|
|
result.Job = CopyRunJobAssignmentPtr(result.Job)
|
|
return result
|
|
}
|
|
|
|
func CopyRunJobReconcile(reconcile RunJobReconcile) RunJobReconcile {
|
|
if reconcile.ActiveJobs != nil {
|
|
reconcile.ActiveJobs = append([]RunJobReconcileEntry(nil), reconcile.ActiveJobs...)
|
|
}
|
|
return reconcile
|
|
}
|
|
|
|
func CopyRunJobReconcileResult(result RunJobReconcileResult) RunJobReconcileResult {
|
|
result.ConfirmedJobs = CopyRunJobAssignments(result.ConfirmedJobs)
|
|
result.DiscardJobIDs = CopyStringSlice(result.DiscardJobIDs)
|
|
return result
|
|
}
|
|
|
|
func CopyRunJobAssignments(assignments []RunJobAssignment) []RunJobAssignment {
|
|
if assignments == nil {
|
|
return nil
|
|
}
|
|
out := make([]RunJobAssignment, len(assignments))
|
|
for index, assignment := range assignments {
|
|
out[index] = CopyRunJobAssignment(assignment)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func CopyDependencyExecutionInput(input DependencyExecutionInput) DependencyExecutionInput {
|
|
input.Probe.Platforms = CopyStringSlice(input.Probe.Platforms)
|
|
input.Plan.Platforms = CopyStringSlice(input.Plan.Platforms)
|
|
input.Plan.Steps = append([]RuntimeInstallStep(nil), input.Plan.Steps...)
|
|
input.Bindings = CopyStringMap(input.Bindings)
|
|
return input
|
|
}
|
|
|
|
func CopySourceRCONExecutionInput(input SourceRCONExecutionInput) SourceRCONExecutionInput {
|
|
return input
|
|
}
|
|
|
|
func CopyRunUpdateChunk(chunk RunUpdateChunk) RunUpdateChunk {
|
|
chunk.Payload = append([]byte(nil), chunk.Payload...)
|
|
return chunk
|
|
}
|