Skip to content

Commit

Permalink
Make possibility to specify configurations for senders
Browse files Browse the repository at this point in the history
- Delayed Job: specified default queue
- Delayed Job: ability to configure queue name
  • Loading branch information
Siarhei Kavaliou committed Feb 17, 2017
1 parent 5a7bac9 commit 99467d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/vero/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Vero
class Config
attr_writer :domain
attr_accessor :api_key, :secret, :development_mode, :async, :disabled, :logging
attr_accessor :api_key, :secret, :development_mode, :async, :disabled, :logging, :senders_config

def self.available_attributes
[:api_key, :secret, :development_mode, :async, :disabled, :logging, :domain]
Expand Down Expand Up @@ -56,6 +56,10 @@ def reset!
self.logging = false
self.api_key = nil
self.secret = nil
self.senders_config = [:delayed_job, :resque, :sidekiq, :sucker_punch].inject({}) do |hash,e|
hash[e] = {}
hash
end
end

def update_attributes(attributes = {})
Expand Down
3 changes: 2 additions & 1 deletion lib/vero/senders/delayed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module Vero
module Senders
class DelayedJob
def call(api_class, domain, options)
response = ::Delayed::Job.enqueue api_class.new(domain, options)
queue = Vero::App.default_context.senders_config.fetch(:delayed_job, {}).fetch(:queue, :default)
response = ::Delayed::Job.enqueue(api_class.new(domain, options), queue: queue)
options_s = JSON.dump(options)
Vero::App.log(self, "method: #{api_class.name}, options: #{options_s}, response: delayed job queued")
response
Expand Down
2 changes: 1 addition & 1 deletion lib/vero/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Vero
VERSION = '0.9.1'
VERSION = '0.9.2'
end

0 comments on commit 99467d7

Please sign in to comment.