This commit is contained in:
2025-11-22 05:40:31 -06:00
parent 87cb54a17d
commit fb2e318eaa
12 changed files with 1891 additions and 353 deletions

View File

@@ -25,18 +25,20 @@ const (
// Job represents a render job
type Job struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
Name string `json:"name"`
Status JobStatus `json:"status"`
Progress float64 `json:"progress"` // 0.0 to 100.0
FrameStart int `json:"frame_start"`
FrameEnd int `json:"frame_end"`
OutputFormat string `json:"output_format"` // PNG, JPEG, EXR, etc.
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
Name string `json:"name"`
Status JobStatus `json:"status"`
Progress float64 `json:"progress"` // 0.0 to 100.0
FrameStart int `json:"frame_start"`
FrameEnd int `json:"frame_end"`
OutputFormat string `json:"output_format"` // PNG, JPEG, EXR, etc.
AllowParallelRunners bool `json:"allow_parallel_runners"` // Allow multiple runners to work on this job
TimeoutSeconds int `json:"timeout_seconds"` // Job-level timeout (24 hours default)
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
// RunnerStatus represents the status of a runner
@@ -72,17 +74,21 @@ const (
// Task represents a render task assigned to a runner
type Task struct {
ID int64 `json:"id"`
JobID int64 `json:"job_id"`
RunnerID *int64 `json:"runner_id,omitempty"`
FrameStart int `json:"frame_start"`
FrameEnd int `json:"frame_end"`
Status TaskStatus `json:"status"`
OutputPath string `json:"output_path,omitempty"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
ID int64 `json:"id"`
JobID int64 `json:"job_id"`
RunnerID *int64 `json:"runner_id,omitempty"`
FrameStart int `json:"frame_start"`
FrameEnd int `json:"frame_end"`
Status TaskStatus `json:"status"`
CurrentStep string `json:"current_step,omitempty"`
RetryCount int `json:"retry_count"`
MaxRetries int `json:"max_retries"`
TimeoutSeconds *int `json:"timeout_seconds,omitempty"` // Task timeout (5 min for frames, 24h for FFmpeg)
OutputPath string `json:"output_path,omitempty"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
// JobFileType represents the type of file
@@ -106,10 +112,11 @@ type JobFile struct {
// CreateJobRequest represents a request to create a new job
type CreateJobRequest struct {
Name string `json:"name"`
FrameStart int `json:"frame_start"`
FrameEnd int `json:"frame_end"`
OutputFormat string `json:"output_format"`
Name string `json:"name"`
FrameStart int `json:"frame_start"`
FrameEnd int `json:"frame_end"`
OutputFormat string `json:"output_format"`
AllowParallelRunners *bool `json:"allow_parallel_runners,omitempty"` // Optional, defaults to true
}
// UpdateJobProgressRequest represents a request to update job progress
@@ -125,3 +132,70 @@ type RegisterRunnerRequest struct {
Capabilities string `json:"capabilities"`
}
// LogLevel represents the level of a log entry
type LogLevel string
const (
LogLevelInfo LogLevel = "INFO"
LogLevelWarn LogLevel = "WARN"
LogLevelError LogLevel = "ERROR"
LogLevelDebug LogLevel = "DEBUG"
)
// TaskLog represents a log entry for a task
type TaskLog struct {
ID int64 `json:"id"`
TaskID int64 `json:"task_id"`
RunnerID *int64 `json:"runner_id,omitempty"`
LogLevel LogLevel `json:"log_level"`
Message string `json:"message"`
StepName string `json:"step_name,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// StepStatus represents the status of a task step
type StepStatus string
const (
StepStatusPending StepStatus = "pending"
StepStatusRunning StepStatus = "running"
StepStatusCompleted StepStatus = "completed"
StepStatusFailed StepStatus = "failed"
StepStatusSkipped StepStatus = "skipped"
)
// TaskStep represents an execution step within a task
type TaskStep struct {
ID int64 `json:"id"`
TaskID int64 `json:"task_id"`
StepName string `json:"step_name"`
Status StepStatus `json:"status"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
DurationMs *int `json:"duration_ms,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
// TaskAnnotation represents an annotation (warning/error) for a task
type TaskAnnotation struct {
ID int64 `json:"id"`
TaskID int64 `json:"task_id"`
StepName string `json:"step_name,omitempty"`
Level LogLevel `json:"level"`
Message string `json:"message"`
Line *int `json:"line,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// SendTaskLogRequest represents a request to send task logs
type SendTaskLogRequest struct {
Logs []TaskLogEntry `json:"logs"`
}
// TaskLogEntry represents a single log entry in a batch request
type TaskLogEntry struct {
LogLevel LogLevel `json:"log_level"`
Message string `json:"message"`
StepName string `json:"step_name,omitempty"`
}