Class: Wurk::Fetcher::Capped::Gate

Inherits:
Struct
  • Object
show all
Defined in:
lib/wurk/fetcher/capped.rb

Overview

One capped queue's ceiling, its slot key, and the local clock that keeps a queue at capacity from costing a round trip per pass. Built once per capped queue at boot: the fetch path never reads a config Hash, and a cap cannot change under a running fetcher anyway (global_concurrency= refuses to run once the configuration is frozen).

One per queue per fetcher, so a capsule's processor threads share it: a refusal is a statement about the cluster, not about the thread that heard it, and suppressing the retry for all of them is the whole saving. They race on blocked_until — the loser writes an equally fresh deadline, and the worst a torn read can cost is one extra round trip. A gate inherited across a fork can carry a stale deadline for the same reason it is harmless: at worst the child's first pass on that queue waits out a backoff it did not earn.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blocked_untilObject

Returns the value of attribute blocked_until

Returns:

  • (Object)

    the current value of blocked_until



59
60
61
# File 'lib/wurk/fetcher/capped.rb', line 59

def blocked_until
  @blocked_until
end

#capacityObject

Returns the value of attribute capacity

Returns:

  • (Object)

    the current value of capacity



59
60
61
# File 'lib/wurk/fetcher/capped.rb', line 59

def capacity
  @capacity
end

#slot_keyObject

Returns the value of attribute slot_key

Returns:

  • (Object)

    the current value of slot_key



59
60
61
# File 'lib/wurk/fetcher/capped.rb', line 59

def slot_key
  @slot_key
end

Instance Method Details

#block!(now) ⇒ Object



62
63
64
# File 'lib/wurk/fetcher/capped.rb', line 62

def block!(now)
  self.blocked_until = now + CAPPED_BACKOFF
end

#blocked?(now) ⇒ Boolean

Returns:

  • (Boolean)


60
# File 'lib/wurk/fetcher/capped.rb', line 60

def blocked?(now) = now < blocked_until