feat(lab5): durable async attachment pipeline through grade 4

- RabbitMQ quorum queue, persistent messages and publisher confirms
- S3 staging plus PostgreSQL attachments/jobs outbox transaction
- worker variants (thumbnail, crop, optimized WebP), DB lease and lease sweeper
- jittered retry, permanent failures, explicit replay and admission cap
- deterministic crash hooks, resilience script and evidence for grade 4
- async-aware custom tests, oversized pixel case, docs and changelog
This commit is contained in:
Mikhail Verkovykh
2026-11-15 00:30:36 +03:00
parent 28d68dc30b
commit 9e43faa536
48 changed files with 4077 additions and 333 deletions
+22
View File
@@ -2,6 +2,7 @@ package common
import (
"encoding/json"
"fmt"
"time"
)
@@ -22,6 +23,27 @@ func (t RFCFormTime) MarshalJSON() ([]byte, error) {
return json.Marshal(utc.Format(layout))
}
// UnmarshalJSON accepts the same RFC 3339 strings MarshalJSON emits. The
// broker round-trips Job values through JSON, and a named time.Time type does
// not inherit encoding/json's time.Time special case on decode.
func (t *RFCFormTime) UnmarshalJSON(data []byte) error {
if string(data) == "null" {
return nil
}
var raw string
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
parsed, err := time.Parse(time.RFC3339Nano, raw)
if err != nil {
return fmt.Errorf("parse RFC form time: %w", err)
}
*t = RFCFormTime(parsed)
return nil
}
func NowUTC() RFCFormTime {
return RFCFormTime(time.Now().UTC().Truncate(storageTimePrecision))
}
+9
View File
@@ -43,6 +43,15 @@ func TestRFCFormTimeSerializesFractionalSeconds(t *testing.T) {
if string(encoded) != tc.want {
t.Fatalf("RFC form time = %s, want %s", encoded, tc.want)
}
var decoded RFCFormTime
if err = json.Unmarshal(encoded, &decoded); err != nil {
t.Fatalf("unmarshal RFC form time: %v", err)
}
want := tc.value.UTC().Truncate(storageTimePrecision)
if !time.Time(decoded).Equal(want) {
t.Fatalf("round trip = %v, want %v", time.Time(decoded), want)
}
})
}
}