128 lines
3.9 KiB
Go
128 lines
3.9 KiB
Go
package types
|
|
|
|
import "time"
|
|
|
|
// User represents a user in the system
|
|
type User struct {
|
|
ID int64 `json:"id"`
|
|
Email string `json:"email"`
|
|
Name string `json:"name"`
|
|
OAuthProvider string `json:"oauth_provider"` // "google" or "discord"
|
|
OAuthID string `json:"oauth_id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// JobStatus represents the status of a job
|
|
type JobStatus string
|
|
|
|
const (
|
|
JobStatusPending JobStatus = "pending"
|
|
JobStatusRunning JobStatus = "running"
|
|
JobStatusCompleted JobStatus = "completed"
|
|
JobStatusFailed JobStatus = "failed"
|
|
JobStatusCancelled JobStatus = "cancelled"
|
|
)
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// RunnerStatus represents the status of a runner
|
|
type RunnerStatus string
|
|
|
|
const (
|
|
RunnerStatusOnline RunnerStatus = "online"
|
|
RunnerStatusOffline RunnerStatus = "offline"
|
|
RunnerStatusBusy RunnerStatus = "busy"
|
|
)
|
|
|
|
// Runner represents a render runner
|
|
type Runner struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Hostname string `json:"hostname"`
|
|
IPAddress string `json:"ip_address"`
|
|
Status RunnerStatus `json:"status"`
|
|
LastHeartbeat time.Time `json:"last_heartbeat"`
|
|
Capabilities string `json:"capabilities"` // JSON string of capabilities
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// TaskStatus represents the status of a task
|
|
type TaskStatus string
|
|
|
|
const (
|
|
TaskStatusPending TaskStatus = "pending"
|
|
TaskStatusRunning TaskStatus = "running"
|
|
TaskStatusCompleted TaskStatus = "completed"
|
|
TaskStatusFailed TaskStatus = "failed"
|
|
)
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// JobFileType represents the type of file
|
|
type JobFileType string
|
|
|
|
const (
|
|
JobFileTypeInput JobFileType = "input"
|
|
JobFileTypeOutput JobFileType = "output"
|
|
)
|
|
|
|
// JobFile represents a file associated with a job
|
|
type JobFile struct {
|
|
ID int64 `json:"id"`
|
|
JobID int64 `json:"job_id"`
|
|
FileType JobFileType `json:"file_type"`
|
|
FilePath string `json:"file_path"`
|
|
FileName string `json:"file_name"`
|
|
FileSize int64 `json:"file_size"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// UpdateJobProgressRequest represents a request to update job progress
|
|
type UpdateJobProgressRequest struct {
|
|
Progress float64 `json:"progress"`
|
|
}
|
|
|
|
// RegisterRunnerRequest represents a request to register a runner
|
|
type RegisterRunnerRequest struct {
|
|
Name string `json:"name"`
|
|
Hostname string `json:"hostname"`
|
|
IPAddress string `json:"ip_address"`
|
|
Capabilities string `json:"capabilities"`
|
|
}
|
|
|