功能修改
This commit is contained in:
@@ -0,0 +1,352 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type CapacityAdmissionState string
|
||||
|
||||
const (
|
||||
CapacityAdmissionAccepted CapacityAdmissionState = "accepted"
|
||||
CapacityAdmissionDeferred CapacityAdmissionState = "deferred"
|
||||
CapacityAdmissionDenied CapacityAdmissionState = "denied"
|
||||
)
|
||||
|
||||
type CapacityPressureCode string
|
||||
|
||||
const (
|
||||
CapacityPressureEndpointOffline CapacityPressureCode = "endpoint.offline"
|
||||
CapacityPressureEndpointStale CapacityPressureCode = "endpoint.stale"
|
||||
CapacityPressureCapabilityGap CapacityPressureCode = "capability.missing"
|
||||
CapacityPressureJobLimit CapacityPressureCode = "job.limit"
|
||||
CapacityPressureQueueLimit CapacityPressureCode = "queue.limit"
|
||||
CapacityPressureBacklog CapacityPressureCode = "spool.backlog"
|
||||
)
|
||||
|
||||
type CapacityAdmissionRequest struct {
|
||||
ServerInstanceID string
|
||||
RunEndpointID string
|
||||
Capability string
|
||||
TargetKey string
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
type CapacityAdmissionDecision struct {
|
||||
Accepted bool
|
||||
State CapacityAdmissionState
|
||||
Reason string
|
||||
RetryAfterSeconds int
|
||||
ServerInstanceID string
|
||||
RunEndpointID string
|
||||
Capability string
|
||||
TargetKey string
|
||||
MaxJobs int
|
||||
RunningJobs int
|
||||
QueuedJobs int
|
||||
PressureCodes []CapacityPressureCode
|
||||
CheckedAt time.Time
|
||||
AlertID string
|
||||
AuditEventID string
|
||||
}
|
||||
|
||||
type EndpointCapacityProjection struct {
|
||||
RunEndpointID string
|
||||
DisplayName string
|
||||
Status RunEndpointStatus
|
||||
Capabilities []string
|
||||
MaxJobs int
|
||||
RunningJobs int
|
||||
QueuedJobs int
|
||||
LogBacklogBatches int
|
||||
ArtifactBacklogChunks int
|
||||
PressureCodes []CapacityPressureCode
|
||||
Summary string
|
||||
LastHeartbeatAt time.Time
|
||||
LastAdmissionDecision CapacityAdmissionState
|
||||
LastAdmissionReason string
|
||||
LastAdmissionCheckedAt time.Time
|
||||
}
|
||||
|
||||
type ProductionCapacitySummary struct {
|
||||
Endpoints []EndpointCapacityProjection
|
||||
TotalMaxJobs int
|
||||
TotalRunningJobs int
|
||||
TotalQueuedJobs int
|
||||
ActiveAlerts int
|
||||
GeneratedAt time.Time
|
||||
}
|
||||
|
||||
type AlertSeverity string
|
||||
|
||||
const (
|
||||
AlertSeverityInfo AlertSeverity = "info"
|
||||
AlertSeverityWarning AlertSeverity = "warning"
|
||||
AlertSeverityCritical AlertSeverity = "critical"
|
||||
)
|
||||
|
||||
type AlertState string
|
||||
|
||||
const (
|
||||
AlertStateActive AlertState = "active"
|
||||
AlertStateAcknowledged AlertState = "acknowledged"
|
||||
AlertStateResolved AlertState = "resolved"
|
||||
)
|
||||
|
||||
type AlertRecord struct {
|
||||
ID string
|
||||
SourceKind string
|
||||
SourceID string
|
||||
RuleKey string
|
||||
Severity AlertSeverity
|
||||
State AlertState
|
||||
Title string
|
||||
Message string
|
||||
OccurrenceCount int
|
||||
Retryable bool
|
||||
RetryAfterSeconds int
|
||||
LastJobID string
|
||||
LastAuditEventID string
|
||||
LastSeenAt time.Time
|
||||
AcknowledgedBy string
|
||||
AcknowledgedAt time.Time
|
||||
ResolvedBy string
|
||||
ResolvedAt time.Time
|
||||
ResolutionNote string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type AlertFilter struct {
|
||||
State AlertState
|
||||
SourceKind string
|
||||
SourceID string
|
||||
Severity AlertSeverity
|
||||
}
|
||||
|
||||
type AlertAcknowledgeRequest struct {
|
||||
AlertID string
|
||||
Note string
|
||||
}
|
||||
|
||||
type AlertResolveRequest struct {
|
||||
AlertID string
|
||||
Note string
|
||||
}
|
||||
|
||||
type AlertRetryRequest struct {
|
||||
AlertID string
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
type AlertRetryResult struct {
|
||||
Alert AlertRecord
|
||||
Decision CapacityAdmissionDecision
|
||||
Status string
|
||||
}
|
||||
|
||||
type PluginLifecycleState string
|
||||
|
||||
const (
|
||||
PluginLifecycleStatePending PluginLifecycleState = "pending"
|
||||
PluginLifecycleStateInstalled PluginLifecycleState = "installed"
|
||||
PluginLifecycleStateEnabled PluginLifecycleState = "enabled"
|
||||
PluginLifecycleStateDisabled PluginLifecycleState = "disabled"
|
||||
PluginLifecycleStateUpgrading PluginLifecycleState = "upgrading"
|
||||
PluginLifecycleStateRollingBack PluginLifecycleState = "rolling_back"
|
||||
PluginLifecycleStateRetired PluginLifecycleState = "retired"
|
||||
PluginLifecycleStateFailed PluginLifecycleState = "failed"
|
||||
)
|
||||
|
||||
type PluginLifecycleOperation string
|
||||
|
||||
const (
|
||||
PluginLifecycleOperationInstall PluginLifecycleOperation = "install"
|
||||
PluginLifecycleOperationEnable PluginLifecycleOperation = "enable"
|
||||
PluginLifecycleOperationDisable PluginLifecycleOperation = "disable"
|
||||
PluginLifecycleOperationUpgrade PluginLifecycleOperation = "upgrade"
|
||||
PluginLifecycleOperationRollback PluginLifecycleOperation = "rollback"
|
||||
PluginLifecycleOperationRetire PluginLifecycleOperation = "retire"
|
||||
PluginLifecycleOperationDependencyCheck PluginLifecycleOperation = "dependency-check"
|
||||
)
|
||||
|
||||
type PluginLifecycleInstallation struct {
|
||||
ID string
|
||||
PluginID string
|
||||
ServerInstanceID string
|
||||
CurrentVersion string
|
||||
TargetVersion string
|
||||
PreviousVersion string
|
||||
DesiredState PluginLifecycleState
|
||||
CurrentState PluginLifecycleState
|
||||
LastOperation PluginLifecycleOperation
|
||||
Compatibility string
|
||||
DependencyState DependencyState
|
||||
JobID string
|
||||
AlertID string
|
||||
AuditEventID string
|
||||
FailureReason string
|
||||
IdempotencyKey string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type PluginLifecycleFilter struct {
|
||||
PluginID string
|
||||
ServerInstanceID string
|
||||
CurrentState PluginLifecycleState
|
||||
}
|
||||
|
||||
type PluginLifecycleRequest struct {
|
||||
PluginID string
|
||||
ServerInstanceID string
|
||||
Operation PluginLifecycleOperation
|
||||
TargetVersion string
|
||||
IdempotencyKey string
|
||||
Confirmed bool
|
||||
}
|
||||
|
||||
type PluginLifecycleResult struct {
|
||||
Installation PluginLifecycleInstallation
|
||||
Job Job
|
||||
Decision CapacityAdmissionDecision
|
||||
Alert *AlertRecord
|
||||
Status string
|
||||
}
|
||||
|
||||
type AIConfigDiffState string
|
||||
|
||||
const (
|
||||
AIConfigDiffStatePending AIConfigDiffState = "pending"
|
||||
AIConfigDiffStateApproved AIConfigDiffState = "approved"
|
||||
AIConfigDiffStateCancelled AIConfigDiffState = "cancelled"
|
||||
AIConfigDiffStateExpired AIConfigDiffState = "expired"
|
||||
)
|
||||
|
||||
type AIConfigDiffPreview struct {
|
||||
ID string
|
||||
RequestID string
|
||||
CreatedBy string
|
||||
ServerInstanceID string
|
||||
PluginID string
|
||||
ProviderID string
|
||||
Model string
|
||||
Key string
|
||||
ConfigVersion int
|
||||
CurrentConfigChecksum string
|
||||
ProposedConfig string
|
||||
DiffSummary string
|
||||
State AIConfigDiffState
|
||||
ExpiresAt time.Time
|
||||
ApprovedBy string
|
||||
ApprovedAt time.Time
|
||||
ApprovalIdempotencyKey string
|
||||
CancelledBy string
|
||||
CancelledAt time.Time
|
||||
JobID string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type AIConfigDiffFilter struct {
|
||||
ServerInstanceID string
|
||||
PluginID string
|
||||
State AIConfigDiffState
|
||||
}
|
||||
|
||||
type AIConfigDiffApprovalRequest struct {
|
||||
DiffID string
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
type AIConfigDiffApprovalResult struct {
|
||||
Preview AIConfigDiffPreview
|
||||
Dispatch ServerConfigWriteDispatch
|
||||
}
|
||||
|
||||
func CopyCapacityAdmissionDecision(decision CapacityAdmissionDecision) CapacityAdmissionDecision {
|
||||
decision.PressureCodes = CopyCapacityPressureCodes(decision.PressureCodes)
|
||||
return decision
|
||||
}
|
||||
|
||||
func CopyEndpointCapacityProjection(projection EndpointCapacityProjection) EndpointCapacityProjection {
|
||||
projection.Capabilities = CopyStringSlice(projection.Capabilities)
|
||||
projection.PressureCodes = CopyCapacityPressureCodes(projection.PressureCodes)
|
||||
return projection
|
||||
}
|
||||
|
||||
func CopyProductionCapacitySummary(summary ProductionCapacitySummary) ProductionCapacitySummary {
|
||||
if summary.Endpoints != nil {
|
||||
summary.Endpoints = append([]EndpointCapacityProjection(nil), summary.Endpoints...)
|
||||
for i := range summary.Endpoints {
|
||||
summary.Endpoints[i] = CopyEndpointCapacityProjection(summary.Endpoints[i])
|
||||
}
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func CopyCapacityPressureCodes(codes []CapacityPressureCode) []CapacityPressureCode {
|
||||
if codes == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]CapacityPressureCode, len(codes))
|
||||
copy(out, codes)
|
||||
return out
|
||||
}
|
||||
|
||||
func CopyAlertRecord(alert AlertRecord) AlertRecord { return alert }
|
||||
|
||||
func CopyAlertRecords(alerts []AlertRecord) []AlertRecord {
|
||||
if alerts == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]AlertRecord, len(alerts))
|
||||
copy(out, alerts)
|
||||
return out
|
||||
}
|
||||
|
||||
func CopyAlertRetryResult(result AlertRetryResult) AlertRetryResult {
|
||||
result.Alert = CopyAlertRecord(result.Alert)
|
||||
result.Decision = CopyCapacityAdmissionDecision(result.Decision)
|
||||
return result
|
||||
}
|
||||
|
||||
func CopyPluginLifecycleInstallation(installation PluginLifecycleInstallation) PluginLifecycleInstallation {
|
||||
return installation
|
||||
}
|
||||
|
||||
func CopyPluginLifecycleInstallations(installations []PluginLifecycleInstallation) []PluginLifecycleInstallation {
|
||||
if installations == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]PluginLifecycleInstallation, len(installations))
|
||||
copy(out, installations)
|
||||
return out
|
||||
}
|
||||
|
||||
func CopyPluginLifecycleResult(result PluginLifecycleResult) PluginLifecycleResult {
|
||||
result.Installation = CopyPluginLifecycleInstallation(result.Installation)
|
||||
result.Job = CopyJob(result.Job)
|
||||
result.Decision = CopyCapacityAdmissionDecision(result.Decision)
|
||||
if result.Alert != nil {
|
||||
alert := CopyAlertRecord(*result.Alert)
|
||||
result.Alert = &alert
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func CopyAIConfigDiffPreview(preview AIConfigDiffPreview) AIConfigDiffPreview {
|
||||
return preview
|
||||
}
|
||||
|
||||
func CopyAIConfigDiffPreviews(previews []AIConfigDiffPreview) []AIConfigDiffPreview {
|
||||
if previews == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]AIConfigDiffPreview, len(previews))
|
||||
copy(out, previews)
|
||||
return out
|
||||
}
|
||||
|
||||
func CopyAIConfigDiffApprovalResult(result AIConfigDiffApprovalResult) AIConfigDiffApprovalResult {
|
||||
result.Preview = CopyAIConfigDiffPreview(result.Preview)
|
||||
result.Dispatch = CopyServerConfigWriteDispatch(result.Dispatch)
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user