A PhoenixReplay.Export.Queue in your Oban
queue: exports survive restarts and deploys, and run on whichever node
of a cluster takes them.
config :phoenix_replay,
export: [
endpoint: MyAppWeb.Endpoint,
queue: {PhoenixReplay.Export.Queue.Oban, oban: Oban, queue: :replay_exports}
]
config :my_app, Oban, queues: [replay_exports: 1]The options:
:oban— your Oban instance (defaultOban):queue— the queue (default:replay_exports), whose limit is how many videos are exported at once, instead of:max_concurrency:timeout— milliseconds an export may run in all before Oban stops it (default one hour), asOban.Worker.timeout/1
Every node that runs the queue needs Chromium and ffmpeg.
Oban keeps one export of a recording at a time, by its unique jobs. A
job's progress is broadcast as it renders, and kept in its meta now
and then, with the node whose disk the video is on. A queued job is
cancelled in Oban; a running one is asked to stop, wherever it runs, so
it closes its browser and stops encoding itself, rather than killed, as
Oban.cancel_job/2 would. A running job no node renders any more is
cancelled in Oban. Videos are deleted after :ttl, and from then on the
job is no longer listed.
In production
As Oban's guide advises, run its plugins:
Oban.Plugins.Lifeline, so an export a deploy or a crash leftexecutingis rescued. Exports are not retried, so it ends failed, and the recording can be exported again.Oban.Plugins.Pruner, so finished jobs are deleted; they are no longer listed once their video is gone, after:ttl.
Progress and the video's place are written to the job's meta while
it runs. Open-source Oban has no API for progress, and documents none
for this; it works because finishing a job changes only its state and
timestamps.
Summary
Functions
The export an Oban job is: its id prefixed oban-, its status from the
job's state, and its progress, video and error from the job's meta.
Functions
@spec to_job(Oban.Job.t()) :: PhoenixReplay.Export.Job.t()
The export an Oban job is: its id prefixed oban-, its status from the
job's state, and its progress, video and error from the job's meta.