Class: Berater::Middleware::LoadShedder
- Inherits:
-
Object
- Object
- Berater::Middleware::LoadShedder
- Defined in:
- lib/berater/middleware/load_shedder.rb
Constant Summary collapse
- PRIORITY_RANGE =
1..5
Instance Method Summary collapse
- #call(*args, **opts) {|args, opts| ... } ⇒ Object
-
#initialize(default_priority: nil) ⇒ LoadShedder
constructor
A new instance of LoadShedder.
Constructor Details
#initialize(default_priority: nil) ⇒ LoadShedder
Returns a new instance of LoadShedder.
6 7 8 |
# File 'lib/berater/middleware/load_shedder.rb', line 6 def initialize(default_priority: nil) @default_priority = default_priority end |
Instance Method Details
#call(*args, **opts) {|args, opts| ... } ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/berater/middleware/load_shedder.rb', line 10 def call(*args, **opts) if priority = opts.delete(:priority) || @default_priority opts[:capacity] = adjust_capacity(opts[:capacity], priority) end yield *args, **opts end |