refactor(*): 数据同步与资源删除 - 收敛服务端真相并保证删除可恢复
This commit is contained in:
@@ -13,6 +13,7 @@ type ChannelScope string
|
||||
type ChannelInterfaceType string
|
||||
type ApiCallStatus string
|
||||
type ResourceStatus string
|
||||
type ResourceDeletionStatus string
|
||||
type BillingStatus string
|
||||
type CreditLedgerType string
|
||||
type RedeemCodeStatus string
|
||||
@@ -91,6 +92,9 @@ const (
|
||||
ResourceStatusFailed ResourceStatus = "failed"
|
||||
ResourceStatusDeleted ResourceStatus = "deleted"
|
||||
|
||||
ResourceDeletionStatusPending ResourceDeletionStatus = "pending"
|
||||
ResourceDeletionStatusProcessing ResourceDeletionStatus = "processing"
|
||||
|
||||
BillingStatusReserved BillingStatus = "reserved"
|
||||
BillingStatusRunning BillingStatus = "running"
|
||||
BillingStatusSettled BillingStatus = "settled"
|
||||
|
||||
@@ -27,6 +27,28 @@ type Resource struct {
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// ResourceDeletionJob is the durable handoff between database deletion and
|
||||
// physical object cleanup. Storage fields are frozen because the Resource row
|
||||
// is removed in the same transaction that creates this job.
|
||||
type ResourceDeletionJob struct {
|
||||
ID string `json:"id" gorm:"primaryKey;size:36"`
|
||||
UserID string `json:"userId" gorm:"index;size:36"`
|
||||
ResourceID string `json:"resourceId" gorm:"index;size:36"`
|
||||
Provider string `json:"provider" gorm:"size:24"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Bucket string `json:"bucket" gorm:"size:160"`
|
||||
StorageSettingID string `json:"-" gorm:"index;size:36"`
|
||||
ObjectKey string `json:"objectKey" gorm:"index"`
|
||||
Status ResourceDeletionStatus `json:"status" gorm:"index:idx_resource_deletion_jobs_due,priority:1;size:24"`
|
||||
Attempts int `json:"attempts"`
|
||||
LastError string `json:"lastError" gorm:"type:text"`
|
||||
NextAttemptAt time.Time `json:"nextAttemptAt" gorm:"index:idx_resource_deletion_jobs_due,priority:2"`
|
||||
LeaseOwner string `json:"-" gorm:"index;size:120"`
|
||||
LeaseExpiresAt *time.Time `json:"-" gorm:"index"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type Asset struct {
|
||||
ID string `json:"id" gorm:"primaryKey;size:80"`
|
||||
UserID string `json:"userId" gorm:"index;size:36;index:idx_assets_user_updated,priority:1"`
|
||||
|
||||
Reference in New Issue
Block a user