Class: Wurk::Limiter::Unlimited

Inherits:
Object
  • Object
show all
Defined in:
lib/wurk/limiter/unlimited.rb

Overview

No-op for the tests + bypass scenarios documented in §1.8. The within_limit block runs unconditionally and the introspection methods all return zeros so dashboards render predictably.

Instance Method Summary collapse

Instance Method Details

#deleteObject



17
# File 'lib/wurk/limiter/unlimited.rb', line 17

def delete = nil

#fingerprintObject



15
# File 'lib/wurk/limiter/unlimited.rb', line 15

def fingerprint = Digest::SHA256.hexdigest('unlimited')

#nameObject



11
# File 'lib/wurk/limiter/unlimited.rb', line 11

def name = 'unlimited'

#optionsObject



13
# File 'lib/wurk/limiter/unlimited.rb', line 13

def options = {}

#resetObject



16
# File 'lib/wurk/limiter/unlimited.rb', line 16

def reset = nil

#sizeObject



14
# File 'lib/wurk/limiter/unlimited.rb', line 14

def size = 0

#statusObject

Uniform status shape (#16): no limit, always available.



20
21
22
# File 'lib/wurk/limiter/unlimited.rb', line 20

def status
  { used: 0, limit: nil, reset_at: nil, available?: true }
end

#typeObject



12
# File 'lib/wurk/limiter/unlimited.rb', line 12

def type = :unlimited

#within_limit(**_kwargs, &block) ⇒ Object

Accept all the kwargs the other limiters take so a worker can swap ‘limiter = Sidekiq::Limiter.unlimited` in tests without touching call sites. `points`-style callers pass an `estimate:` and expect a `|handle|` block param — we yield a zero-cost handle just in case.

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
36
# File 'lib/wurk/limiter/unlimited.rb', line 28

def within_limit(**_kwargs, &block)
  raise ArgumentError, 'block required' unless block

  if block.arity.zero?
    block.call
  else
    block.call(Points::Handle.new(self, 0))
  end
end