feat: 完整游戏运维功能

This commit is contained in:
npc0-hue
2026-07-18 09:04:01 +08:00
parent f3b14b7945
commit 48b8ad8d6c
187 changed files with 16607 additions and 1140 deletions
+144 -31
View File
@@ -18,8 +18,14 @@ type RunJobAssignment struct {
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
}
@@ -72,16 +78,18 @@ type RunJobProgressResult struct {
}
type RunJobResult struct {
RunEndpointID string
SessionToken string
JobID string
LeaseToken string
Attempt int
State JobState
Progress RunJobProgressReport
ResultRef string
Message string
ErrorCode string
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 {
@@ -107,6 +115,7 @@ type DistributionBuildInput struct {
ProfileKey string
TargetOS string
TargetArch string
TargetRelease string
PackageFormat string
RepositoryURL string
SourceRevision string
@@ -117,6 +126,103 @@ type DistributionBuildInput struct {
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 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
@@ -127,6 +233,8 @@ type RunJobCancelRequestResult struct {
JobID string
Reason string
RequestedAt time.Time
CompletedAt time.Time
State JobState
}
type RunJobCancelPoll struct {
@@ -134,6 +242,7 @@ type RunJobCancelPoll struct {
SessionToken string
JobID string
LeaseToken string
Attempt int
}
type RunJobCancelPollResult struct {
@@ -146,33 +255,26 @@ type RunJobCancelPollResult struct {
ServerTime time.Time
}
type RunJobReconcileEntry struct {
JobID string
LeaseToken string
Attempt int
}
type RunJobReconcile struct {
RunEndpointID string
SessionToken string
ActiveJobIDs []string
ActiveJobs []RunJobReconcileEntry
}
type RunJobReconcileResult struct {
Accepted bool
RunEndpointID string
ActiveJobs []RunJobAssignment
UnknownJobIDs []string
ConfirmedJobs []RunJobAssignment
DiscardJobIDs []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
}
@@ -196,13 +298,15 @@ func CopyRunJobClaimResult(result RunJobClaimResult) RunJobClaimResult {
}
func CopyRunJobReconcile(reconcile RunJobReconcile) RunJobReconcile {
reconcile.ActiveJobIDs = CopyStringSlice(reconcile.ActiveJobIDs)
if reconcile.ActiveJobs != nil {
reconcile.ActiveJobs = append([]RunJobReconcileEntry(nil), reconcile.ActiveJobs...)
}
return reconcile
}
func CopyRunJobReconcileResult(result RunJobReconcileResult) RunJobReconcileResult {
result.ActiveJobs = CopyRunJobAssignments(result.ActiveJobs)
result.UnknownJobIDs = CopyStringSlice(result.UnknownJobIDs)
result.ConfirmedJobs = CopyRunJobAssignments(result.ConfirmedJobs)
result.DiscardJobIDs = CopyStringSlice(result.DiscardJobIDs)
return result
}
@@ -215,6 +319,15 @@ func CopyRunJobAssignments(assignments []RunJobAssignment) []RunJobAssignment {
return out
}
func CopyRunJobLease(lease RunJobLease) RunJobLease {
return lease
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 CopyRunUpdateChunk(chunk RunUpdateChunk) RunUpdateChunk {
chunk.Payload = append([]byte(nil), chunk.Payload...)
return chunk
}