Files
mtusi2026lab7/internal/domain/attachment_job.go
T
2026-11-22 23:33:11 +03:00

58 lines
1.5 KiB
Go

package domain
import "time"
const AttachmentJobType = "attachment.process.v1"
type AttachmentJobStatus string
const (
AttachmentJobQueued AttachmentJobStatus = "queued"
AttachmentJobProcessing AttachmentJobStatus = "processing"
AttachmentJobSucceeded AttachmentJobStatus = "succeeded"
AttachmentJobFailed AttachmentJobStatus = "failed"
AttachmentJobSuperseded AttachmentJobStatus = "superseded"
)
type AttachmentJob struct {
SchemaVersion int
JobID string
Type string
AttachmentID string
PipelineVersion int
Attempt int
MaxAttempts int
Status AttachmentJobStatus
ErrorCode *string
AvailableAt time.Time
LeaseUntil *time.Time
LeasedBy *string
ReplayCount int
CreatedAt time.Time
UpdatedAt time.Time
TraceParent string
TraceState string
}
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"`
}
func (job AttachmentJob) Message() AttachmentJobMessage {
return AttachmentJobMessage{
SchemaVersion: job.SchemaVersion,
JobID: job.JobID,
Type: job.Type,
AttachmentID: job.AttachmentID,
PipelineVersion: job.PipelineVersion,
Attempt: job.Attempt,
CreatedAt: job.CreatedAt.UTC(),
}
}