diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 18:07:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 18:07:42 +0000 |
commit | 7b52c7cb634ef7047d30b0337fe477bcdcedf41d (patch) | |
tree | 374ca9e908204488422046f10e340d1500780362 /app/workers/concerns/worker_attributes.rb | |
parent | b375c6c05fbd03aea33a9ee9f82e678bdaa8c3cc (diff) | |
download | gitlab-ce-7b52c7cb634ef7047d30b0337fe477bcdcedf41d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers/concerns/worker_attributes.rb')
-rw-r--r-- | app/workers/concerns/worker_attributes.rb | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/app/workers/concerns/worker_attributes.rb b/app/workers/concerns/worker_attributes.rb index 55feba673c4..216f73b58e2 100644 --- a/app/workers/concerns/worker_attributes.rb +++ b/app/workers/concerns/worker_attributes.rb @@ -4,9 +4,12 @@ module WorkerAttributes extend ActiveSupport::Concern # Resource boundaries that workers can declare through the - # `worker_resource_boundary` attribute + # `resource_boundary` attribute VALID_RESOURCE_BOUNDARIES = [:memory, :cpu, :unknown].freeze + # Urgencies that workers can declare through the `urgencies` attribute + VALID_URGENCIES = [:high, :default, :none].freeze + NAMESPACE_WEIGHTS = { auto_devops: 2, auto_merge: 3, @@ -47,21 +50,22 @@ module WorkerAttributes get_worker_attribute(:feature_category) == :not_owned end - # This should be set for jobs that need to be run immediately, or, if - # they are delayed, risk creating inconsistencies in the application - # that could being perceived by the user as incorrect behavior - # (ie, a bug) - # See doc/development/sidekiq_style_guide.md#Latency-Sensitive-Jobs + # This should be set to :high for jobs that need to be run + # immediately, or, if they are delayed, risk creating + # inconsistencies in the application that could being perceived by + # the user as incorrect behavior (ie, a bug) + # + # See + # doc/development/sidekiq_style_guide.md#urgency # for details - def latency_sensitive_worker! - worker_attributes[:latency_sensitive] = true + def urgency(urgency) + raise "Invalid urgency: #{urgency}" unless VALID_URGENCIES.include?(urgency) + + worker_attributes[:urgency] = urgency end - # Returns a truthy value if the worker is latency sensitive. - # See doc/development/sidekiq_style_guide.md#Latency-Sensitive-Jobs - # for details - def latency_sensitive_worker? - worker_attributes[:latency_sensitive] + def get_urgency + worker_attributes[:urgency] || :default end # Set this attribute on a job when it will call to services outside of the |