Module: Sidekiq

Defined in:
lib/sidekiq.rb,
lib/sidekiq/cli.rb,
lib/sidekiq/util.rb,
lib/sidekiq/rails.rb,
lib/sidekiq/client.rb,
lib/sidekiq/worker.rb,
lib/sidekiq/manager.rb,
lib/sidekiq/testing.rb,
lib/sidekiq/version.rb,
lib/sidekiq/processor.rb,
lib/sidekiq/middleware/chain.rb,
lib/sidekiq/redis_connection.rb,
lib/sidekiq/extensions/action_mailer.rb,
lib/sidekiq/extensions/active_record.rb,
lib/sidekiq/extensions/generic_proxy.rb,
lib/sidekiq/middleware/server/logging.rb,
lib/sidekiq/middleware/client/unique_jobs.rb,
lib/sidekiq/middleware/server/unique_jobs.rb,
lib/sidekiq/middleware/server/failure_jobs.rb,
lib/sidekiq/middleware/server/active_record.rb,
lib/sidekiq/middleware/server/exception_handler.rb,
lib/sidekiq/middleware/client/resque_web_compatibility.rb

Defined Under Namespace

Modules: Extensions, Middleware, Util, Worker Classes: CLI, Client, Manager, Processor, Rails, RedisConnection

Constant Summary collapse

DEFAULTS =
{
  :queues => [],
  :concurrency => 25,
  :require => '.',
  :environment => nil,
}
VERSION =
"0.8.0"

Class Method Summary collapse

Class Method Details

.client_middleware {|@client_chain| ... } ⇒ Object

Yields:

  • (@client_chain)

72
73
74
75
76
# File 'lib/sidekiq.rb', line 72

def self.client_middleware
  @client_chain ||= Client.default_middleware
  yield @client_chain if block_given?
  @client_chain
end

.configure_client {|_self| ... } ⇒ Object

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

Yields:

  • (_self)

Yield Parameters:

  • _self (Sidekiq)

    the object that the method was called on


46
47
48
# File 'lib/sidekiq.rb', line 46

def self.configure_client
  yield self unless server?
end

.configure_server {|_self| ... } ⇒ Object

Configuration for Sidekiq server, use like:

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

Yields:

  • (_self)

Yield Parameters:

  • _self (Sidekiq)

    the object that the method was called on


36
37
38
# File 'lib/sidekiq.rb', line 36

def self.configure_server
  yield self if server?
end

.optionsObject


19
20
21
# File 'lib/sidekiq.rb', line 19

def self.options
  @options ||= DEFAULTS.dup
end

.options=(opts) ⇒ Object


23
24
25
# File 'lib/sidekiq.rb', line 23

def self.options=(opts)
  @options = opts
end

.redisObject


54
55
56
# File 'lib/sidekiq.rb', line 54

def self.redis
  @redis ||= Sidekiq::RedisConnection.create
end

.redis=(hash) ⇒ Object


58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/sidekiq.rb', line 58

def self.redis=(hash)
  if !hash.is_a?(Hash)
    puts "*****************************************************
Sidekiq.redis now takes a Hash:
old: Sidekiq.redis = Sidekiq::RedisConnection.create(:url => 'redis://foo.com', :namespace => 'abc', :size => 12)
new: Sidekiq.redis = { :url => 'redis://foo.com', :namespace => 'xyz', :size => 12 }
Called from #{caller[0]}
*****************************************************"
    @redis = hash
  else
    @redis = RedisConnection.create(hash)
  end
end

.server?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'lib/sidekiq.rb', line 50

def self.server?
  defined?(Sidekiq::CLI)
end

.server_middleware {|@server_chain| ... } ⇒ Object

Yields:

  • (@server_chain)

78
79
80
81
82
# File 'lib/sidekiq.rb', line 78

def self.server_middleware
  @server_chain ||= Processor.default_middleware
  yield @server_chain if block_given?
  @server_chain
end