diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/workers/concerns/application_worker.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/workers/concerns/application_worker.rb')
-rw-r--r-- | app/workers/concerns/application_worker.rb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/app/workers/concerns/application_worker.rb b/app/workers/concerns/application_worker.rb index 7ab9a0c2a02..9c942228111 100644 --- a/app/workers/concerns/application_worker.rb +++ b/app/workers/concerns/application_worker.rb @@ -76,6 +76,22 @@ module ApplicationWorker get_sidekiq_options['queue'].to_s end + # Set/get which arguments can be logged and sent to Sentry. + # + # Numeric arguments are logged by default, so there is no need to + # list those. + # + # Non-numeric arguments must be listed by position, as Sidekiq + # cannot see argument names. + # + def loggable_arguments(*args) + if args.any? + @loggable_arguments = args + else + @loggable_arguments || [] + end + end + def queue_size Sidekiq::Queue.new(queue).size end @@ -84,7 +100,7 @@ module ApplicationWorker Sidekiq::Client.push_bulk('class' => self, 'args' => args_list) end - def bulk_perform_in(delay, args_list) + def bulk_perform_in(delay, args_list, batch_size: nil, batch_delay: nil) now = Time.now.to_i schedule = now + delay.to_i @@ -92,7 +108,14 @@ module ApplicationWorker raise ArgumentError, _('The schedule time must be in the future!') end - Sidekiq::Client.push_bulk('class' => self, 'args' => args_list, 'at' => schedule) + if batch_size && batch_delay + args_list.each_slice(batch_size.to_i).with_index do |args_batch, idx| + batch_schedule = schedule + idx * batch_delay.to_i + Sidekiq::Client.push_bulk('class' => self, 'args' => args_batch, 'at' => batch_schedule) + end + else + Sidekiq::Client.push_bulk('class' => self, 'args' => args_list, 'at' => schedule) + end end end end |