feat(uploads): the job carries the duration the file claimed (review F2)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.d-ma.be/mathias/tapir/internal/domain"
|
"git.d-ma.be/mathias/tapir/internal/domain"
|
||||||
)
|
)
|
||||||
@@ -33,6 +34,9 @@ type Job struct {
|
|||||||
UserID string
|
UserID string
|
||||||
UploadID string
|
UploadID string
|
||||||
Path string
|
Path string
|
||||||
|
// Duration is what the file CLAIMED when probed. The worker compares it with what
|
||||||
|
// was really converted; zero means unknown (ADR-035 review).
|
||||||
|
Duration time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submitter hands accepted jobs to the in-process worker (ADR-033).
|
// Submitter hands accepted jobs to the in-process worker (ADR-033).
|
||||||
@@ -103,7 +107,7 @@ func (in *Intake) Accept(ctx context.Context, userID, title string, src io.Reade
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("uploads: create: %w", err)
|
return "", fmt.Errorf("uploads: create: %w", err)
|
||||||
}
|
}
|
||||||
if err := in.sub.Submit(Job{UserID: userID, UploadID: id, Path: path}); err != nil {
|
if err := in.sub.Submit(Job{UserID: userID, UploadID: id, Path: path, Duration: probe.Duration}); err != nil {
|
||||||
// A row that will never run must not sit queued: that is the stuck spinner.
|
// A row that will never run must not sit queued: that is the stuck spinner.
|
||||||
if ferr := in.store.FailUpload(ctx, userID, id, domain.UploadErrInterrupted); ferr != nil {
|
if ferr := in.store.FailUpload(ctx, userID, id, domain.UploadErrInterrupted); ferr != nil {
|
||||||
return "", fmt.Errorf("uploads: submit: %w (and failing the row: %v)", err, ferr)
|
return "", fmt.Errorf("uploads: submit: %w (and failing the row: %v)", err, ferr)
|
||||||
|
|||||||
Reference in New Issue
Block a user