Module: Wurk::Web::Enterprise::Periodic
- Defined in:
- lib/wurk/web/enterprise.rb
Overview
Periodic tab — list/pause/unpause/enqueue-now/history. The list view reuses ‘Wurk::Cron::LoopSet`; mutating actions write directly to the `loops:lid` HASH so they’re idempotent and crash-safe.
Class Method Summary collapse
-
.enqueue_now(lid) ⇒ Object
Spec §2.4 “enqueue-now”: pushes a one-off run with the loop’s configured klass/queue/args/retry.
- .fetch(lid) ⇒ Object
-
.history(lid) ⇒ Object
Spec §8.0.1+: per-loop history list at ‘loop-history:lid`.
- .list ⇒ Object
- .pause(lid) ⇒ Object
-
.set_paused(lid, value) ⇒ Object
rubocop:disable Naming/PredicateMethod.
- .unpause(lid) ⇒ Object
Class Method Details
.enqueue_now(lid) ⇒ Object
Spec §2.4 “enqueue-now”: pushes a one-off run with the loop’s configured klass/queue/args/retry. Returns the new jid, or nil when the loop doesn’t exist.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/wurk/web/enterprise.rb', line 78 def enqueue_now(lid) loop_obj = fetch(lid) return nil unless loop_obj Wurk::Client.new.push( 'class' => loop_obj.klass, 'args' => loop_obj.args, 'queue' => loop_obj.queue, 'retry' => loop_obj.retry_value ) end |
.fetch(lid) ⇒ Object
63 64 65 |
# File 'lib/wurk/web/enterprise.rb', line 63 def fetch(lid) Wurk::Cron::LoopSet.new.fetch(lid) end |
.history(lid) ⇒ Object
Spec §8.0.1+: per-loop history list at ‘loop-history:lid`. Each entry is a `[fired_at, jid]` tuple (LPUSH’d by the poller).
92 93 94 95 96 97 |
# File 'lib/wurk/web/enterprise.rb', line 92 def history(lid) loop_obj = fetch(lid) return [] unless loop_obj loop_obj.history end |
.list ⇒ Object
59 60 61 |
# File 'lib/wurk/web/enterprise.rb', line 59 def list Wurk::Cron::LoopSet.new end |
.pause(lid) ⇒ Object
67 68 69 |
# File 'lib/wurk/web/enterprise.rb', line 67 def pause(lid) set_paused(lid, '1') end |
.set_paused(lid, value) ⇒ Object
rubocop:disable Naming/PredicateMethod
99 100 101 102 103 104 105 |
# File 'lib/wurk/web/enterprise.rb', line 99 def set_paused(lid, value) # rubocop:disable Naming/PredicateMethod loop_obj = fetch(lid) return false unless loop_obj Wurk.redis { |c| c.call('HSET', "#{Wurk::Cron::LOOP_PREFIX}#{lid}", 'paused', value) } true end |
.unpause(lid) ⇒ Object
71 72 73 |
# File 'lib/wurk/web/enterprise.rb', line 71 def unpause(lid) set_paused(lid, '0') end |