Skip to content

Instantly share code, notes, and snippets.

@storuky
Created January 25, 2016 11:16
Show Gist options
  • Save storuky/fd0e88e615d5bc9af7b3 to your computer and use it in GitHub Desktop.
Save storuky/fd0e88e615d5bc9af7b3 to your computer and use it in GitHub Desktop.
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