diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-05 15:12:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-05 15:12:58 +0300 |
commit | c9b0dfef1ba43a9e04264023b08c589bcb9eb397 (patch) | |
tree | 4ea24fc43fe40e3c133e64e2476e0be42dafc10b /lib/gitlab/endpoint_attributes | |
parent | e0c90aab261896abcf93f3806d965790dbd03408 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/endpoint_attributes')
-rw-r--r-- | lib/gitlab/endpoint_attributes/config.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/gitlab/endpoint_attributes/config.rb b/lib/gitlab/endpoint_attributes/config.rb index f36f9671929..e31a3095736 100644 --- a/lib/gitlab/endpoint_attributes/config.rb +++ b/lib/gitlab/endpoint_attributes/config.rb @@ -3,14 +3,14 @@ module Gitlab module EndpointAttributes class Config - Duration = Struct.new(:name, :duration) - TARGET_DURATIONS = [ - Duration.new(:very_fast, 0.25), - Duration.new(:fast, 0.5), - Duration.new(:medium, 1), - Duration.new(:slow, 5) + RequestUrgency = Struct.new(:name, :duration) + REQUEST_URGENCIES = [ + RequestUrgency.new(:high, 0.25), + RequestUrgency.new(:medium, 0.5), + RequestUrgency.new(:default, 1), + RequestUrgency.new(:low, 5) ].index_by(&:name).freeze - SUPPORTED_ATTRIBUTES = %i[feature_category target_duration].freeze + SUPPORTED_ATTRIBUTES = %i[feature_category urgency].freeze def initialize @default_attributes = {} @@ -38,8 +38,8 @@ module Gitlab def attribute_for_action(action, attribute_name) value = @action_attributes.dig(action.to_s, attribute_name) || @default_attributes[attribute_name] - # Translate target duration to a representative struct - value = TARGET_DURATIONS[value] if attribute_name == :target_duration + # Translate urgency to a representative struct + value = REQUEST_URGENCIES[value] if attribute_name == :urgency value end @@ -49,8 +49,8 @@ module Gitlab unsupported_attributes = (attributes.keys - SUPPORTED_ATTRIBUTES).present? raise ArgumentError, "Attributes not supported: #{unsupported_attributes.join(", ")}" if unsupported_attributes - if attributes[:target_duration].present? && !TARGET_DURATIONS.key?(attributes[:target_duration]) - raise ArgumentError, "Target duration not supported: #{attributes[:target_duration]}" + if attributes[:urgency].present? && !REQUEST_URGENCIES.key?(attributes[:urgency]) + raise ArgumentError, "Urgency not supported: #{attributes[:urgency]}" end end |