• Sean McGivern's avatar
    Add ApplicationWorker.with_status for checking job status · afadb20f
    Sean McGivern authored
    Add `ApplicationWorker.with_status`, which sets the `status_expiration`
    field on a Sidekiq job. In a future change, this will be required to
    check the job's status with Gitlab::SidekiqStatus.
    
    If the worker class defines its own `status_expiration`, then we use
    that; otherwise we fall back to
    `Gitlab::SidekiqStatus::DEFAULT_EXPIRATION`.
    
    This commit also changes several cases where we assign to a `job_id` or
    `jid` variable to the result of a Sidekiq worker's `perform_async`
    method. There are some cases where we don't need that, of course: if we
    don't actually use the job's ID to check its status then `with_status`
    is unnecessary.
    
    For instance, many classes in Gitlab::Geo::LogCursor::Events log a job
    ID but don't persist it elsewhere to check the status; the pipeline
    schedules API uses the job ID to check if a worker was scheduled or not.
    afadb20f
worker.rb 3.5 KB