feat: add durable image processing pipeline

This commit is contained in:
2026-10-22 17:22:28 +03:00
parent 8c2ac690a6
commit 42336ce7c2
39 changed files with 4379 additions and 126 deletions
+6
View File
@@ -15,4 +15,10 @@ var (
ErrPayloadTooLarge = errors.New("payload too large")
ErrCapacity = errors.New("capacity exhausted")
ErrUnavailable = errors.New("dependency unavailable")
ErrStaleLease = errors.New("stale lease")
ErrStaleAttempt = errors.New("stale attempt")
ErrStalePipeline = errors.New("stale pipeline")
ErrJobBusy = errors.New("job is already leased")
ErrJobComplete = errors.New("job is already complete")
ErrJobNotDue = errors.New("job is not due")
)
+94 -24
View File
@@ -6,9 +6,21 @@ import (
)
const (
AttachmentPending = "pending"
AttachmentReady = "ready"
AttachmentDeleting = "deleting"
AttachmentPending = "pending"
AttachmentQueued = "queued"
AttachmentProcessing = "processing"
AttachmentReady = "ready"
AttachmentFailed = "failed"
AttachmentDeleting = "deleting"
AttachmentJobQueued = "queued"
AttachmentJobProcessing = "processing"
AttachmentJobReady = "ready"
AttachmentJobFailed = "failed"
JobMutationApplied JobMutationResult = "applied"
JobMutationAlreadyComplete JobMutationResult = "already_complete"
JobMutationStale JobMutationResult = "stale"
)
const timestampLayout = "2006-01-02T15:04:05.000000Z"
@@ -42,21 +54,23 @@ type Message struct {
}
type Attachment struct {
ID string `json:"id"`
ChatID string `json:"chat_id"`
OwnerID string `json:"owner_id"`
Filename string `json:"filename"`
ContentType string `json:"content_type"`
SizeBytes int64 `json:"size_bytes"`
SHA256 string `json:"sha256"`
Status string `json:"status"`
Variants []Variant `json:"variants"`
ErrorCode *string `json:"error_code"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ObjectKey string `json:"-"`
ReadyAt *time.Time `json:"-"`
Referenced bool `json:"-"`
ID string `json:"id"`
ChatID string `json:"chat_id"`
OwnerID string `json:"owner_id"`
Filename string `json:"filename"`
ContentType string `json:"content_type"`
SizeBytes int64 `json:"size_bytes"`
SHA256 string `json:"sha256"`
Status string `json:"status"`
Variants []Variant `json:"variants"`
ErrorCode *string `json:"error_code"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ObjectKey string `json:"-"`
StagingKey string `json:"-"`
ReadyAt *time.Time `json:"-"`
Referenced bool `json:"-"`
PipelineVersion int `json:"-"`
}
type StoredObject struct {
@@ -66,12 +80,68 @@ type StoredObject struct {
}
type Variant struct {
Name string `json:"name"`
ContentType string `json:"content_type"`
SizeBytes int64 `json:"size_bytes"`
SHA256 string `json:"sha256"`
Width int `json:"width"`
Height int `json:"height"`
Name string `json:"name"`
ContentType string `json:"content_type"`
SizeBytes int64 `json:"size_bytes"`
SHA256 string `json:"sha256"`
Width int `json:"width"`
Height int `json:"height"`
ObjectKey string `json:"-"`
PipelineVersion int `json:"-"`
}
type AttachmentJob struct {
ID string
AttachmentID string
PipelineVersion int
Attempt int
Status string
AvailableAt time.Time
LeaseToken string
LeaseOwner string
LeaseUntil *time.Time
ErrorCode *string
CreatedAt time.Time
UpdatedAt time.Time
}
type AttachmentJobMessage struct {
SchemaVersion int `json:"schema_version"`
JobID string `json:"job_id"`
Type string `json:"type"`
AttachmentID string `json:"attachment_id"`
PipelineVersion int `json:"pipeline_version"`
Attempt int `json:"attempt"`
CreatedAt time.Time `json:"created_at"`
Traceparent string `json:"traceparent,omitempty"`
Tracestate string `json:"tracestate,omitempty"`
}
type AttachmentJobLease struct {
Job AttachmentJob
Attachment Attachment
}
type OutboxEvent struct {
ID string
Topic string
PartitionKey string
Payload json.RawMessage
JobID string
Attempt int
AvailableAt time.Time
PublishTries int
LeaseToken string
LeaseUntil *time.Time
LastErrorCode *string
CreatedAt time.Time
}
type JobMutationResult string
type RecoveryResult struct {
Requeued int
Failed int
}
type Position struct {