first commit
This commit is contained in:
@@ -0,0 +1,193 @@
|
||||
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
|
||||
LeaseToken string
|
||||
Attempt int
|
||||
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
|
||||
}
|
||||
|
||||
type RunJobResultResult struct {
|
||||
Accepted bool
|
||||
Job RunJobAssignment
|
||||
ServerTime time.Time
|
||||
}
|
||||
|
||||
type RunJobCancelRequest struct {
|
||||
JobID string
|
||||
Reason string
|
||||
}
|
||||
|
||||
type RunJobCancelRequestResult struct {
|
||||
Accepted bool
|
||||
JobID string
|
||||
Reason string
|
||||
RequestedAt time.Time
|
||||
}
|
||||
|
||||
type RunJobCancelPoll struct {
|
||||
RunEndpointID string
|
||||
SessionToken string
|
||||
JobID string
|
||||
LeaseToken string
|
||||
}
|
||||
|
||||
type RunJobCancelPollResult struct {
|
||||
Accepted bool
|
||||
RunEndpointID string
|
||||
HasCancel bool
|
||||
JobID string
|
||||
Reason string
|
||||
RequestedAt time.Time
|
||||
ServerTime time.Time
|
||||
}
|
||||
|
||||
type RunJobReconcile struct {
|
||||
RunEndpointID string
|
||||
SessionToken string
|
||||
ActiveJobIDs []string
|
||||
}
|
||||
|
||||
type RunJobReconcileResult struct {
|
||||
Accepted bool
|
||||
RunEndpointID string
|
||||
ActiveJobs []RunJobAssignment
|
||||
UnknownJobIDs []string
|
||||
ServerTime time.Time
|
||||
}
|
||||
|
||||
type RunJobLease struct {
|
||||
JobID string
|
||||
RunEndpointID string
|
||||
SessionToken string
|
||||
LeaseToken string
|
||||
Attempt int
|
||||
CancelReason string
|
||||
CancelRequestedAt time.Time
|
||||
TerminalFingerprint string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func CopyRunJobAssignment(assignment RunJobAssignment) RunJobAssignment {
|
||||
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 {
|
||||
reconcile.ActiveJobIDs = CopyStringSlice(reconcile.ActiveJobIDs)
|
||||
return reconcile
|
||||
}
|
||||
|
||||
func CopyRunJobReconcileResult(result RunJobReconcileResult) RunJobReconcileResult {
|
||||
result.ActiveJobs = CopyRunJobAssignments(result.ActiveJobs)
|
||||
result.UnknownJobIDs = CopyStringSlice(result.UnknownJobIDs)
|
||||
return result
|
||||
}
|
||||
|
||||
func CopyRunJobAssignments(assignments []RunJobAssignment) []RunJobAssignment {
|
||||
if assignments == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]RunJobAssignment, len(assignments))
|
||||
copy(out, assignments)
|
||||
return out
|
||||
}
|
||||
|
||||
func CopyRunJobLease(lease RunJobLease) RunJobLease {
|
||||
return lease
|
||||
}
|
||||
Reference in New Issue
Block a user