Class: Wurk::IterableJobQuery

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/wurk/iterable_job_query.rb

Overview

Read-side data API for IterableJob progress. Bulk-reads the ‘it-<jid>` HASHes (sidekiq-free.md §1.5) in a single pipeline so dashboards and tools can introspect many iterable jobs without N round trips. The runtime that writes those HASHes lives in Wurk::IterableJob; this is the reader.

Aliased Sidekiq::IterableJobQuery.

Spec: docs/target/sidekiq-free.md §19.9.

Defined Under Namespace

Classes: State

Instance Method Summary collapse

Constructor Details

#initialize(jids) ⇒ IterableJobQuery

Returns a new instance of IterableJobQuery.

Parameters:

  • jids (Array<String>)

    job ids to query.



32
33
34
# File 'lib/wurk/iterable_job_query.rb', line 32

def initialize(jids)
  @states = fetch(Array(jids))
end

Instance Method Details

#[](jid) ⇒ State?

Returns state for jid, or nil when no ‘it-<jid>` HASH exists (e.g. a non-iterable job, or one whose state has expired).

Returns:

  • (State, nil)

    state for jid, or nil when no ‘it-<jid>` HASH exists (e.g. a non-iterable job, or one whose state has expired).



38
# File 'lib/wurk/iterable_job_query.rb', line 38

def [](jid) = @states[jid]

#eachObject

Yields each present State, in the order its jid was supplied. Jids with no state are skipped — only iterable jobs with live state appear.



42
# File 'lib/wurk/iterable_job_query.rb', line 42

def each(&) = @states.each_value(&)