1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/lib/sidekiq.rb
Mike Perham 6af6a86369 Refactor middleware API, this will break anyone using the old API.
e.g.
Sidekiq::Processor.middleware => Sidekiq.server_middleware
Sidekiq::Client.middleware => Sidekiq.client_middleware
2012-02-18 12:12:05 -08:00

51 lines
1.2 KiB
Ruby

require 'sidekiq/version'
require 'sidekiq/client'
require 'sidekiq/worker'
require 'sidekiq/rails' if defined?(::Rails)
require 'sidekiq/redis_connection'
require 'sidekiq/extensions/action_mailer'
require 'sidekiq/extensions/active_record'
require 'sidekiq/middleware/chain'
require 'sidekiq/middleware/server/active_record'
require 'sidekiq/middleware/server/airbrake'
require 'sidekiq/middleware/server/unique_jobs'
require 'sidekiq/middleware/client/resque_web_compatibility'
require 'sidekiq/middleware/client/unique_jobs'
module Sidekiq
def self.redis
@redis ||= Sidekiq::RedisConnection.create
end
def self.redis=(r)
@redis = r
end
def self.client_middleware
@client_chain ||= begin
m = Middleware::Chain.new
m.add Middleware::Client::UniqueJobs
m.add Middleware::Client::ResqueWebCompatibility
m
end
yield @client_chain if block_given?
@client_chain
end
def self.server_middleware
@server_chain ||= begin
m = Middleware::Chain.new
m.add Middleware::Server::Airbrake
m.add Middleware::Server::UniqueJobs
m.add Middleware::Server::ActiveRecord
m
end
yield @server_chain if block_given?
@server_chain
end
end