Class: Ryespy::Notifier::Sidekiq
- Inherits:
-
Object
- Object
- Ryespy::Notifier::Sidekiq
- Defined in:
- lib/ryespy/notifier/sidekiq.rb
Constant Summary collapse
- SIDEKIQ_QUEUE =
'ryespy'.freeze
- SIDEKIQ_KEY_QUEUES =
'queues'.freeze
- SIDEKIQ_KEY_QUEUE_X =
"queue:#{SIDEKIQ_QUEUE}".freeze
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(opts = {}) ⇒ Sidekiq
constructor
A new instance of Sidekiq.
- #notify(job_class, args) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Sidekiq
Returns a new instance of Sidekiq.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ryespy/notifier/sidekiq.rb', line 16 def initialize(opts = {}) @redis_config = { :url => opts[:url], :namespace => opts[:namespace], } @logger = opts[:logger] || Logger.new(nil) connect_redis if block_given? yield self close end end |
Instance Method Details
#close ⇒ Object
33 34 35 |
# File 'lib/ryespy/notifier/sidekiq.rb', line 33 def close @redis.quit end |
#notify(job_class, args) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/ryespy/notifier/sidekiq.rb', line 37 def notify(job_class, args) @redis.sadd(SIDEKIQ_KEY_QUEUES, SIDEKIQ_QUEUE) sidekiq_job_payload = sidekiq_job(job_class, args) @logger.debug { "Setting Redis Key #{SIDEKIQ_KEY_QUEUE_X} Payload #{sidekiq_job_payload.to_json}" } @redis.rpush(SIDEKIQ_KEY_QUEUE_X, sidekiq_job_payload.to_json) end |