Initial AI service skeleton
This commit is contained in:
71
internal/model/job.go
Normal file
71
internal/model/job.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
StatusPending = "pending"
|
||||
StatusRunning = "running"
|
||||
StatusDone = "done"
|
||||
StatusFailed = "failed"
|
||||
StatusCancelled = "cancelled"
|
||||
)
|
||||
|
||||
type Job struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
OwnerService string `json:"owner_service"`
|
||||
OwnerRef string `json:"owner_ref"`
|
||||
TaskType string `json:"task_type"`
|
||||
ModelProfile string `json:"model_profile"`
|
||||
Priority int `json:"priority"`
|
||||
Status string `json:"status"`
|
||||
Attempts int `json:"attempts"`
|
||||
MaxAttempts int `json:"max_attempts"`
|
||||
Input json.RawMessage `json:"input"`
|
||||
Result json.RawMessage `json:"result,omitempty"`
|
||||
ErrorCode *string `json:"error_code,omitempty"`
|
||||
ErrorMessage *string `json:"error_message,omitempty"`
|
||||
ScheduledAt time.Time `json:"scheduled_at"`
|
||||
StartedAt *time.Time `json:"started_at,omitempty"`
|
||||
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
IdempotencyKey *string `json:"idempotency_key,omitempty"`
|
||||
}
|
||||
|
||||
type CreateJob struct {
|
||||
OwnerService string `json:"owner_service"`
|
||||
OwnerRef string `json:"owner_ref"`
|
||||
TaskType string `json:"task_type"`
|
||||
ModelProfile string `json:"model_profile"`
|
||||
Priority int `json:"priority"`
|
||||
MaxAttempts int `json:"max_attempts"`
|
||||
Input json.RawMessage `json:"input"`
|
||||
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
|
||||
IdempotencyKey *string `json:"idempotency_key,omitempty"`
|
||||
}
|
||||
|
||||
type QueueStat struct {
|
||||
TaskType string `json:"task_type"`
|
||||
ModelProfile string `json:"model_profile"`
|
||||
Status string `json:"status"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type ErrorStat struct {
|
||||
TaskType string `json:"task_type"`
|
||||
ModelProfile string `json:"model_profile"`
|
||||
ErrorCode string `json:"error_code"`
|
||||
Total int64 `json:"total"`
|
||||
Last24h int64 `json:"last_24h"`
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
At time.Time `json:"at"`
|
||||
Queues []QueueStat `json:"queues"`
|
||||
Errors []ErrorStat `json:"errors,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user