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

#delete ⇒ Object



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

def delete = nil

#fingerprint ⇒ Object



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

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

#name ⇒ Object



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

def name = 'unlimited'

#options ⇒ Object



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

def options = {}

#reset ⇒ Object



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

def reset = nil

#size ⇒ Object



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

def size = 0

#status ⇒ Object

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



18
19
20
# File 'lib/wurk/limiter/unlimited.rb', line 18

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

#type ⇒ Object



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

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)


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

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