feat(lab5): time pipeline stages and centralize variant constants

This commit is contained in:
Mikhail Verkovykh
2026-11-20 19:05:27 +03:00
parent 1ce93185af
commit d0f533b371
5 changed files with 121 additions and 36 deletions
+12
View File
@@ -12,6 +12,18 @@ import (
"github.com/jackc/pgx/v5"
)
// Job state machine. Every transition is a compare-and-set on
// (job_id, attempt, status), so broker duplicates and stale workers are
// harmless.
//
// queued --ClaimJob--> processing --CompleteJob--> ready
// |
// +--ScheduleRetry--> queued (future available_at)
// +--FailJob--------> failed
// +--attempt >= max-> failed/retry_exhausted
// processing with an expired lease --RecoverExpiredLeases--> queued/failed
// failed --ReplayFailed--> queued (attempt=0, replay_count+1)
//
// ClaimResult tells the consumer whether this delivery owns the work.
type ClaimResult struct {
Job model.JobRecord