Rindle.Workers.MuxSyncCoordinator (Rindle v0.1.5)

Copy Markdown View Source

Oban cron worker that fans out per-row sync jobs for media_provider_assets rows in (processing, uploading) older than provider_polling_floor_seconds.

Delegates per-row work to MuxSyncProviderAsset. No sync logic lives here. Adopters can schedule this worker from their Oban cron config without requiring Rindle to supervise Oban.

Cron Configuration Example

In your Oban configuration:

config :my_app, Oban,
  queues: [rindle_provider: 4],
  plugins: [
    {Oban.Plugins.Cron,
     crontab: [
       {"* * * * *", Rindle.Workers.MuxSyncCoordinator}
     ]}
  ]

Cron resolution is 1 minute (Oban.Plugins.Cron docs); the coordinator's internal query enforces the provider_polling_floor_seconds: 30 floor so rows that were just touched by a webhook (Phase 35) are not redundantly polled.

Job Arguments

This worker accepts no arguments. All behavior is driven by the :provider_polling_floor_seconds config under config :rindle, Rindle.Streaming.Provider.Mux.

Return Contract

  • :ok — fan-out completed; per-row jobs enqueued.
  • Coordinator runs with max_attempts: 1 because a missed cron tick is always cheaper to skip and re-run on the next tick than to retry mid-fanout.

Backpressure (Pitfall 6 mitigation)

Per-row unique constraint (unique: [period: 60, keys: [:provider_asset_id]]) deduplicates within the 60s window — the second cron tick will not re-fan-out a still-running per-row job. Phase 34 ships unbounded scan; if real-world adopter feedback shows queue floods (>1k stuck rows), add a LIMIT cap in v1.7.

Observability

  • Logger.info("rindle.workers.mux_sync_coordinator.completed", ...) — emitted after each fan-out with rows_scanned, jobs_enqueued, and floor_seconds. The coordinator emits no per-row telemetry — that responsibility lives with MuxSyncProviderAsset per row, with redacted asset_id metadata.

Telemetry

This worker emits NO [:rindle, :provider, :sync, _] events itself — the per-row MuxSyncProviderAsset worker is the source of truth for telemetry. The coordinator logs structured events under Logger.info("rindle.workers.mux_sync_coordinator.completed", ...) for operator visibility.