Created
January 25, 2016 11:16
-
-
Save storuky/fd0e88e615d5bc9af7b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sidekiq::Middleware::DefaultUrlOptions | |
class Client | |
def call(worker_class, msg, queue, redis_pool) | |
msg['default_url_options'] = ActionMailer::Base.default_url_options | |
yield | |
end | |
end | |
class Server | |
def call(worker, msg, queue) | |
if default_url_options = msg['default_url_options'] | |
ActionMailer::Base.default_url_options = default_url_options.symbolize_keys | |
yield | |
else | |
yield | |
end | |
end | |
end | |
end | |
Sidekiq.configure_client do |config| | |
config.client_middleware do |chain| | |
chain.add Sidekiq::Middleware::DefaultUrlOptions::Client | |
end | |
end | |
Sidekiq.configure_server do |config| | |
config.client_middleware do |chain| | |
chain.add Sidekiq::Middleware::DefaultUrlOptions::Client | |
end | |
config.server_middleware do |chain| | |
chain.add Sidekiq::Middleware::DefaultUrlOptions::Server | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment