feat(db): lab5 add failed_jobs table and repository
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
// FailedJob — реестр окончательно проваленных задач (DLQ-сторона).
|
||||
// Заполняется worker'ом после исчерпания retry или при permanent-ошибке.
|
||||
// Читается для операторского просмотра и для явного replay (Этап 5).
|
||||
type FailedJob struct {
|
||||
ID string
|
||||
AttachmentID string
|
||||
ReasonCode string // из jobcodes.go
|
||||
Attempts int
|
||||
LastErrorAt time.Time
|
||||
ResolvedAt *time.Time // nil = не разобрана
|
||||
Resolution string // "replayed", "manual_fix", ...
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -57,9 +57,15 @@ type AttachmentJobRepository interface {
|
||||
ClaimForProcessing(ctx context.Context, id string, lease time.Duration) (*Attachment, error)
|
||||
CompleteJob(ctx context.Context, id string, pipelineVersion int, variants []AttachmentVariant) (bool, error)
|
||||
FailJob(ctx context.Context, id string, errorCode string) error
|
||||
ScheduleRetry(ctx context.Context, id string, nextAttemptAt time.Time, errorCode string) error
|
||||
}
|
||||
|
||||
type AttachmentVariantRepository interface {
|
||||
Upsert(ctx context.Context, tx Tx, v *AttachmentVariant) error
|
||||
ListByAttachment(ctx context.Context, id string) ([]AttachmentVariant, error)
|
||||
}
|
||||
|
||||
type FailedJobRepository interface {
|
||||
Record(ctx context.Context, f *FailedJob) error
|
||||
Resolve(ctx context.Context, attachmentID string, resolution string) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user