Skip to the content.

Variant processing sequence

This diagram abbreviates materializeChild as enqueue plus run; admin-local explicit materialization always uses that synchronous method. Successful image transforms use sharp through transformImage with byte/operation/decode limits. SVG/audio/video/model/document registry entries are stub objects throwing TransformerNotImplementedError, not implemented processing classes. Worker acknowledges persisted terminal failures, throws for fresh leases and retryable faults. Dispatch failure calls failMaterializeDispatch. Replacement invalidation failures are audited. Lease checks protect catalog finalization; they do not atomically fence writes to the shared blob key.

Legend: all drawn relationships are source-verified; branches are conditional execution paths. No inferred service is drawn.

sequenceDiagram
  participant R as Materialize route or thumbnail helper
  participant L as MediaLibrary
  participant C as Catalog and jobs
  participant Q as SQS
  participant W as Media worker
  participant B as Blob store
  participant T as TransformerRegistry / ImageTransformer
  R->>L: Enqueue pending child and queued job
  L->>C: Persist child/job and enqueue audit
  alt MEDIA_QUEUE_URL configured on AWS backend
    R->>Q: Send jobId
    Q->>W: Deliver message
    W->>L: runMaterializeJob(jobId)
  else Synchronous
    R->>L: runMaterializeJob(jobId)
  end
  L->>C: Claim queued job or reclaim stale lease
  alt Fresh running lease or terminal job
    L-->>R: Existing status (worker retries fresh lease)
  else Claimed
    L->>B: stat then get original
    L->>T: Resolve kind and materialize recipe
    alt Image transform succeeds
      T-->>L: Encoded bytes, contentType, metadata
      L->>B: Put deterministic variant key
      L->>C: Check parent and finalize with lease condition
      L->>L: Optional replacement invalidation, audit
    else Unsupported kind or invalid recipe
      L->>C: Failed job and failed child, or preserved previous ready child
    else Infrastructure failure
      L->>C: Requeue if lease still owned
      L-->>W: Throw for SQS retry
    end
  end

Source evidence