haixunMaster/haixun-backend/internal/model/job/domain/entity/run.go

53 lines
2.2 KiB
Go

package entity
import (
"haixun-backend/internal/model/job/domain/enum"
"go.mongodb.org/mongo-driver/bson/primitive"
)
const RunCollectionName = "job_runs"
type StepProgress struct {
ID string `bson:"id"`
Status enum.StepStatus `bson:"status"`
StartedAt *int64 `bson:"started_at,omitempty"`
EndedAt *int64 `bson:"ended_at,omitempty"`
Message string `bson:"message,omitempty"`
}
type RunProgress struct {
Summary string `bson:"summary"`
Percentage int `bson:"percentage"`
Steps []StepProgress `bson:"steps"`
}
type Run struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
TenantID string `bson:"tenant_id,omitempty"`
OwnerUID string `bson:"owner_uid,omitempty"`
TemplateType string `bson:"template_type"`
TemplateVersion int `bson:"template_version"`
Scope string `bson:"scope"`
ScopeID string `bson:"scope_id"`
Status enum.RunStatus `bson:"status"`
Phase string `bson:"phase"`
WorkerType string `bson:"worker_type"`
Payload map[string]any `bson:"payload"`
Progress RunProgress `bson:"progress"`
Result map[string]any `bson:"result,omitempty"`
Error string `bson:"error,omitempty"`
Attempt int `bson:"attempt"`
MaxAttempts int `bson:"max_attempts"`
DedupeKey string `bson:"dedupe_key,omitempty"`
LockedBy string `bson:"locked_by,omitempty"`
LockedUntil *int64 `bson:"locked_until,omitempty"`
CancelRequestedAt *int64 `bson:"cancel_requested_at,omitempty"`
CancelReason string `bson:"cancel_reason,omitempty"`
ScheduledAt *int64 `bson:"scheduled_at,omitempty"`
StartedAt *int64 `bson:"started_at,omitempty"`
CompletedAt *int64 `bson:"completed_at,omitempty"`
CreateAt int64 `bson:"create_at"`
UpdateAt int64 `bson:"update_at"`
}