lib/rworkflow/sidekiq_helper.rb in rworkflow-0.6.5 vs lib/rworkflow/sidekiq_helper.rb in rworkflow-0.7.0

- old
+ new

@@ -1,44 +1,23 @@ require 'sidekiq/api' module Rworkflow module SidekiqHelper def self.included(klass) - klass.send :extend, ClassMethods - klass.send :include, InstanceMethods + klass.send :extend, ClassMethods end module ClassMethods # Mix-in methods def enqueue_job(*params) - enqueue_job_with_priority(nil, *params) - end - - def enqueue_job_with_priority(priority, *params) if should_perform_job_async? - self.perform_with_priority(priority, *params) + self.perform_async(*params) else inline_perform(params) end end - def enqueue_job_at(at_time, *params) - if should_perform_job_async? - self.perform_at(at_time, *params) - else - inline_perform(params) - end - end - - def enqueue_job_in(time_diff, *params) - if should_perform_job_async? - self.perform_in(time_diff, *params) - else - inline_perform(params) - end - end - def should_perform_job_async? return Rworkflow.config.sidekiq_perform_async end def inline_perform(params) @@ -48,37 +27,29 @@ worker.jid = jid worker.perform(*args) end end - module InstanceMethods - end - # Static methods class << self - def configure_server host, port, db + def configure_server(host, port, db) Sidekiq.configure_server do |config| - config.redis = {:url => "redis://#{host}:#{port}/#{db}", :namespace => 'sidekiq'} + config.redis = { url: "redis://#{host}:#{port}/#{db}", namespace: 'sidekiq' } config.server_middleware do |chain| chain.add SidekiqServerMiddleware end end end - def configure_client host, port, db + def configure_client(host, port, db) Sidekiq.configure_client do |config| - config.redis = {:url => "redis://#{host}:#{port}/#{db}", :namespace => 'sidekiq'} + config.redis = { url: "redis://#{host}:#{port}/#{db}", namespace: 'sidekiq' } end end - def get_queue_sizes + def queue_sizes stats = Sidekiq::Stats.new return stats.queues - end - - def get_queue_sizes_sum - stats = Sidekiq::Stats.new - return stats.enqueued end end end end