forked from mtusi2026/mtusi2026lab5
- RabbitMQ quorum queue, persistent messages and publisher confirms - S3 staging plus PostgreSQL attachments/jobs outbox transaction - worker variants (thumbnail, crop, optimized WebP), DB lease and lease sweeper - jittered retry, permanent failures, explicit replay and admission cap - deterministic crash hooks, resilience script and evidence for grade 4 - async-aware custom tests, oversized pixel case, docs and changelog
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gitflic.ru/project/bulla-max/mtusi2026lab/internal/common"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Job is the broker payload described by contracts/jobs.schema.json. It never
|
|
// contains image bytes, bucket keys or credentials: the worker reloads trusted
|
|
// metadata from PostgreSQL by attachment_id.
|
|
type Job struct {
|
|
SchemaVersion int `json:"schema_version"`
|
|
JobID uuid.UUID `json:"job_id"`
|
|
Type string `json:"type"`
|
|
AttachmentID uuid.UUID `json:"attachment_id"`
|
|
PipelineVersion int `json:"pipeline_version"`
|
|
Attempt int `json:"attempt"`
|
|
CreatedAt common.RFCFormTime `json:"created_at"`
|
|
}
|
|
|
|
const (
|
|
JobTypeAttachmentProcessV1 = "attachment.process.v1"
|
|
|
|
JobStatusQueued = "queued"
|
|
JobStatusProcessing = "processing"
|
|
JobStatusReady = "ready"
|
|
JobStatusFailed = "failed"
|
|
)
|
|
|
|
// JobRecord is the durable outbox row plus the operator-visible job state.
|
|
type JobRecord struct {
|
|
Job
|
|
Status string
|
|
// AvailableAt is the earliest time the outbox may publish a retry.
|
|
AvailableAt time.Time
|
|
// PublishedAt nil means the outbox has not received a publisher confirm
|
|
// yet. This is the recovery marker for a crash between COMMIT and publish.
|
|
PublishedAt *time.Time
|
|
LeaseUntil *time.Time
|
|
ProcessingStartedAt *time.Time
|
|
FinishedAt *time.Time
|
|
MaxAttempts int
|
|
ErrorCode *string
|
|
ReplayCount int
|
|
}
|