wurk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/wurk/cron.rb +29 -0
- data/lib/wurk/version.rb +1 -1
- data/vendor/assets/dashboard/wurk-manifest.json +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dc76b5c62f729370d36c966fdbd391aa77bc0cdd9edfc64148024351a52e3191
|
|
4
|
+
data.tar.gz: 7293ddf887066f715c5263ea9eceb92b5c05bc5a8324651fa857cc4b2486f215
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c571b8c549c76c48f12aa7bdc5d249cbcd1fed5f17f08ad96a4621d836e02c9bd587b0d0d22c9e713fa90778a1e48c065063d5d3deb6ca9e109e5bee606430a
|
|
7
|
+
data.tar.gz: 6c0056e1f4b18f4d63ecb5a5b790fdf2d81ea1cc2a650af8fde6c901181bf858cf602c21b689cd363869cd0301e9981eb3707f2f8a69335f1b9ba7dfa995a355
|
data/lib/wurk/cron.rb
CHANGED
|
@@ -574,6 +574,9 @@ module Wurk
|
|
|
574
574
|
end
|
|
575
575
|
|
|
576
576
|
def enqueue!(loop_obj)
|
|
577
|
+
aj = active_job_class(loop_obj.klass)
|
|
578
|
+
return enqueue_active_job(aj, loop_obj) if aj
|
|
579
|
+
|
|
577
580
|
@client.push(
|
|
578
581
|
'class' => loop_obj.klass,
|
|
579
582
|
'args' => loop_obj.args,
|
|
@@ -582,6 +585,32 @@ module Wurk
|
|
|
582
585
|
)
|
|
583
586
|
end
|
|
584
587
|
|
|
588
|
+
# Resolve a loop's class name to an ActiveJob::Base subclass, or nil when
|
|
589
|
+
# ActiveJob isn't loaded (standalone wurk) or the class isn't one.
|
|
590
|
+
# sidekiq-cron parity: a cron loop targeting an ActiveJob must enqueue
|
|
591
|
+
# through the AJ adapter so the job runs via Sidekiq::ActiveJob::Wrapper
|
|
592
|
+
# with full callbacks/serialization — a bare `client.push('class' => …)`
|
|
593
|
+
# would make the processor call `Klass.new.perform`, skipping all of AJ.
|
|
594
|
+
def active_job_class(name)
|
|
595
|
+
return nil unless defined?(::ActiveJob::Base)
|
|
596
|
+
|
|
597
|
+
const = name.split('::').inject(::Object) { |mod, c| mod.const_get(c) }
|
|
598
|
+
const if const.is_a?(::Class) && const < ::ActiveJob::Base
|
|
599
|
+
rescue ::NameError
|
|
600
|
+
nil
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
# Enqueue via the AJ adapter (→ wurk). Only override the queue when the
|
|
604
|
+
# loop set one explicitly; otherwise the job's own `queue_as` wins. AJ's
|
|
605
|
+
# `retry_on`/`discard_on` govern retries, so the Sidekiq `retry` option
|
|
606
|
+
# doesn't apply here. Returns the wurk jid (provider_job_id) so the fire
|
|
607
|
+
# history records it; nil if a before_enqueue callback halted the push.
|
|
608
|
+
def enqueue_active_job(klass, loop_obj)
|
|
609
|
+
target = loop_obj.queue == 'default' ? klass : klass.set(queue: loop_obj.queue)
|
|
610
|
+
job = target.perform_later(*loop_obj.args)
|
|
611
|
+
job.provider_job_id if job.respond_to?(:provider_job_id)
|
|
612
|
+
end
|
|
613
|
+
|
|
585
614
|
def read_fire_marks(lid)
|
|
586
615
|
@config.redis do |c|
|
|
587
616
|
vals = c.call('HMGET', "#{LOOP_PREFIX}#{lid}", 'lf', 'nf')
|
data/lib/wurk/version.rb
CHANGED