1. 31 Jan, 2020 1 commit
    • Bob Van Landuyt's avatar
      Allow scheduling jobs in batch with contexts · 01b394f0
      Bob Van Landuyt authored
      This adds helper methods for the `bulk_perform_in` and
      `bulk_perform_async` methods that allow specifying a context per job.
      
      Scheduling jobs with contexts that need to be different based on the
      arguments passed can be done by passing in an array of objects, and
      defining how to build arguments and contexts for those objects.
      
      For example:
            ProjectImportScheduleWorker.bulk_perform_async_with_contexts(
              projects,
              arguments_proc: -> (project) { project.id },
              context_proc: -> (project) { { project: project } }
            )
      
      This will schedule `ProjectImportScheduleWorker` jobs called with the
      project.id. And will create contexts using the project. The developers
      need to make sure that the required resources for building a context
      are loaded: The route and the namespace of a project.
      
      The batch context will be stored on the worker class when scheduling
      the job, so the sidekiq middleware can fetch the right context based
      on those arguments and apply them to the job when scheduling it.
      
      This also implements this method for the `UpdateAllMirrorsWorker`
      which schedules `ProjectImportScheduleWorker` in batch. When adding
      this, the `ProjectImportScheduleWorker`-jobs will have a context.
      01b394f0
  2. 30 Jan, 2020 34 commits
  3. 29 Jan, 2020 5 commits