Files
2025-07-23 12:22:29 +00:00

20 lines
594 B
Ruby

# frozen_string_literal: true
module Gitlab
module SidekiqMiddleware
module Throttling
module Strategy
StrategyStruct = Struct.new(:name, :concurrency_operator)
SoftThrottle = StrategyStruct.new("SoftThrottle", ->(limit) { [(0.8 * limit).ceil, 1].max })
HardThrottle = StrategyStruct.new("HardThrottle", ->(limit) { [(0.5 * limit).ceil, 1].max })
GradualRecovery = StrategyStruct.new("GradualRecovery", ->(limit) { [limit + 1, (limit * 1.1).floor].max })
# no-op
None = StrategyStruct.new("None", nil)
end
end
end
end