feat(cloud-agent): 云端 Agent - 完善运行时与资源持久化
This commit is contained in:
1 parent
48e6a705ef
commit
993580a7bd
40 files changed
+1739
-440
No files matched your search
@@ -53,9 +53,29 @@ type cloudAgentTaskBillingFacts struct {
|
||||
ReservedAmountMicrocredits int64 `json:"reservedAmountMicrocredits,omitempty"`
|
||||
ActualAmountMicrocredits int64 `json:"actualAmountMicrocredits,omitempty"`
|
||||
RefundedAmountMicrocredits int64 `json:"refundedAmountMicrocredits,omitempty"`
|
||||
ReservedCredits float64 `json:"reservedCredits"`
|
||||
ActualCredits float64 `json:"actualCredits"`
|
||||
RefundedCredits float64 `json:"refundedCredits"`
|
||||
ChargeState string `json:"chargeState"`
|
||||
ChargeSummary string `json:"chargeSummary"`
|
||||
StateAvailable bool `json:"stateAvailable"`
|
||||
}
|
||||
|
||||
func cloudAgentChargeState(status model.BillingStatus) (string, string) {
|
||||
switch status {
|
||||
case model.BillingStatusSettled:
|
||||
return "settled", "已结算,实际扣费以 actualCredits 为准"
|
||||
case model.BillingStatusRefunded:
|
||||
return "refunded", "已退款,本次不计入已消费"
|
||||
case model.BillingStatusReserved, model.BillingStatusRunning:
|
||||
return "pending", "仅预授权/执行中,尚未确认实际扣费"
|
||||
case model.BillingStatusUncertain:
|
||||
return "uncertain", "扣费状态待确认,不得称为已扣费"
|
||||
default:
|
||||
return "unknown", "扣费状态未知,不得称为已扣费"
|
||||
}
|
||||
}
|
||||
|
||||
func cloudAgentTaskDiagnostic(repo *repository.Repository, task *model.Task) map[string]any {
|
||||
if task == nil {
|
||||
return map[string]any{"taskStatus": "unavailable", "taskSubmitted": false, "submissionOutcome": "unavailable"}
|
||||
@@ -98,6 +118,10 @@ func cloudAgentTaskDiagnostic(repo *repository.Repository, task *model.Task) map
|
||||
facts.Billing.ReservedAmountMicrocredits = order.ReservedAmountMicrocredits
|
||||
facts.Billing.ActualAmountMicrocredits = order.ActualAmountMicrocredits
|
||||
facts.Billing.RefundedAmountMicrocredits = order.RefundedAmountMicrocredits
|
||||
facts.Billing.ReservedCredits = float64(order.ReservedAmountMicrocredits) / float64(CreditScale)
|
||||
facts.Billing.ActualCredits = float64(order.ActualAmountMicrocredits) / float64(CreditScale)
|
||||
facts.Billing.RefundedCredits = float64(order.RefundedAmountMicrocredits) / float64(CreditScale)
|
||||
facts.Billing.ChargeState, facts.Billing.ChargeSummary = cloudAgentChargeState(order.Status)
|
||||
facts.Billing.StateAvailable = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user