diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /lib/gitlab/sidekiq_versioning/worker.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'lib/gitlab/sidekiq_versioning/worker.rb')
-rw-r--r-- | lib/gitlab/sidekiq_versioning/worker.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/gitlab/sidekiq_versioning/worker.rb b/lib/gitlab/sidekiq_versioning/worker.rb new file mode 100644 index 00000000000..fe9bae6b8a1 --- /dev/null +++ b/lib/gitlab/sidekiq_versioning/worker.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Gitlab + module SidekiqVersioning + module Worker + extend ActiveSupport::Concern + + included do + version 0 + + attr_writer :job_version + end + + class_methods do + def version(new_version = nil) + if new_version + sidekiq_options version: new_version.to_i + else + get_sidekiq_options['version'] + end + end + end + + # Version is not set if `new.perform` is called directly, + # and in that case we fallback to latest version + def job_version + @job_version ||= self.class.version + end + end + end +end |