Then we wait

Release the DB connection and sleep until the job is done

class Website::RenditionJob < ApplicationJob
  # new(cache).enqueue.wait
  #                   ^^^^
  def wait(timeout: TIMEOUT)
    ActiveRecord::Base.connection_pool
      .release_connection   # give it back
    channel.pop(timeout:)   # 💤 sleep here
    self
  end
end
19 / 45