mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Split configuration into configure_server and configure_client blocks.
This commit is contained in:
parent
429dc44d36
commit
a242600a08
3 changed files with 25 additions and 7 deletions
|
@ -25,15 +25,30 @@ module Sidekiq
|
|||
end
|
||||
|
||||
##
|
||||
# Configuration for Sidekiq, use like:
|
||||
# Configuration for Sidekiq server, use like:
|
||||
#
|
||||
# Sidekiq.configure do |config|
|
||||
# Sidekiq.configure_server do |config|
|
||||
# config.redis = Sidekiq::RedisConnection.create(:namespace => 'myapp', :size => 25, :url => 'redis://myhost:8877/mydb')
|
||||
# config.server_middleware do |chain|
|
||||
# chain.add MyServerHook
|
||||
# end
|
||||
# end
|
||||
def self.configure
|
||||
yield self
|
||||
def self.configure_server
|
||||
yield self if server?
|
||||
end
|
||||
|
||||
##
|
||||
# Configuration for Sidekiq client, use like:
|
||||
#
|
||||
# Sidekiq.configure_client do |config|
|
||||
# config.redis = Sidekiq::RedisConnection.create(:namespace => 'myapp', :size => 1, :url => 'redis://myhost:8877/mydb')
|
||||
# end
|
||||
def self.configure_client
|
||||
yield self unless server?
|
||||
end
|
||||
|
||||
def self.server?
|
||||
defined?(Sidekiq::CLI)
|
||||
end
|
||||
|
||||
def self.redis
|
||||
|
|
|
@ -6,7 +6,7 @@ module Sidekiq
|
|||
def self.create(options={})
|
||||
url = options[:url] || ENV['REDISTOGO_URL'] || 'redis://localhost:6379/0'
|
||||
client = build_client(url, options[:namespace])
|
||||
return ConnectionPool.new(:timeout => 1, :size => Sidekiq.options[:concurrency] || 25) { client } unless options[:use_pool] == false
|
||||
return ConnectionPool.new(:timeout => 1, :size => (options[:size] || Sidekiq.options[:concurrency] || 25)) { client } unless options[:use_pool] == false
|
||||
client
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
Sidekiq.configure do |config|
|
||||
config.redis = Sidekiq::RedisConnection.create(:namespace => 'resque', :size => 5)
|
||||
Sidekiq.configure_client do |config|
|
||||
config.redis = Sidekiq::RedisConnection.create(:namespace => 'resque', :size => 2)
|
||||
end
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = Sidekiq::RedisConnection.create(:namespace => 'resque', :size => 25)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue