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.
152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/wurk/web/enterprise.rb', line 152 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
137 138 139 |
# File 'lib/wurk/web/enterprise.rb', line 137 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).
166 167 168 169 170 171 |
# File 'lib/wurk/web/enterprise.rb', line 166 def history(lid) loop_obj = fetch(lid) return [] unless loop_obj loop_obj.history end |
.list ⇒ Object
133 134 135 |
# File 'lib/wurk/web/enterprise.rb', line 133 def list Wurk::Cron::LoopSet.new end |
.pause(lid) ⇒ Object
141 142 143 |
# File 'lib/wurk/web/enterprise.rb', line 141 def pause(lid) set_paused(lid, '1') end |
.set_paused(lid, value) ⇒ Object
rubocop:disable Naming/PredicateMethod
173 174 175 176 177 178 179 |
# File 'lib/wurk/web/enterprise.rb', line 173 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
145 146 147 |
# File 'lib/wurk/web/enterprise.rb', line 145 def unpause(lid) set_paused(lid, '0') end |