1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Improved API rdoc

This commit is contained in:
Mike Perham 2016-01-18 10:59:09 -05:00
parent d6538b0b4f
commit 877b528aaf
2 changed files with 17 additions and 17 deletions

View file

@ -35,10 +35,8 @@ module Sidekiq
# Sidekiq::Client.new(ConnectionPool.new { Redis.new })
#
# Generally this is only needed for very large Sidekiq installs processing
# more than thousands jobs per second. I do not recommend sharding unless
# you truly cannot scale any other way (e.g. splitting your app into smaller apps).
# Some features, like the API, do not support sharding: they are designed to work
# against a single Redis instance only.
# thousands of jobs per second. I don't recommend sharding unless you
# cannot scale any other way (e.g. splitting your app into smaller apps).
def initialize(redis_pool=nil)
@redis_pool = redis_pool || Thread.current[:sidekiq_via_pool] || Sidekiq.redis_pool
end
@ -49,11 +47,12 @@ module Sidekiq
# queue - the named queue to use, default 'default'
# class - the worker class to call, required
# args - an array of simple arguments to the perform method, must be JSON-serializable
# retry - whether to retry this job if it fails, true or false, default true
# retry - whether to retry this job if it fails, default true or an integer number of retries
# backtrace - whether to save any error backtrace, default false
#
# All options must be strings, not symbols. NB: because we are serializing to JSON, all
# symbols in 'args' will be converted to strings.
# symbols in 'args' will be converted to strings. Note that +backtrace: true+ can take quite a bit of
# space in Redis; a large volume of failing jobs can start Redis swapping if you aren't careful.
#
# Returns a unique Job ID. If middleware stops the job, nil will be returned instead.
#
@ -72,9 +71,8 @@ module Sidekiq
##
# Push a large number of jobs to Redis. In practice this method is only
# useful if you are pushing tens of thousands of jobs or more, or if you need
# to ensure that a batch doesn't complete prematurely. This method
# basically cuts down on the redis round trip latency.
# useful if you are pushing thousands of jobs or more. This method
# cuts out the redis network round trip latency.
#
# Takes the same arguments as #push except that args is expected to be
# an Array of Arrays. All other keys are duplicated for each job. Each job
@ -104,10 +102,8 @@ module Sidekiq
# end
#
# Generally this is only needed for very large Sidekiq installs processing
# more than thousands jobs per second. I do not recommend sharding unless
# you truly cannot scale any other way (e.g. splitting your app into smaller apps).
# Some features, like the API, do not support sharding: they are designed to work
# against a single Redis instance.
# thousands of jobs per second. I do not recommend sharding unless
# you cannot scale any other way (e.g. splitting your app into smaller apps).
def self.via(pool)
raise ArgumentError, "No pool given" if pool.nil?
raise RuntimeError, "Sidekiq::Client.via is not re-entrant" if x = Thread.current[:sidekiq_via_pool] && x != pool

View file

@ -79,11 +79,15 @@ module Sidekiq
# Allows customization for this type of Worker.
# Legal options:
#
# :queue - use a named queue for this Worker, default 'default'
# :retry - enable the RetryJobs middleware for this Worker, default *true*
# :backtrace - whether to save any error backtrace in the retry payload to display in web UI,
# queue - use a named queue for this Worker, default 'default'
# retry - enable the RetryJobs middleware for this Worker, *true* to use the default
# or *Integer* count
# backtrace - whether to save any error backtrace in the retry payload to display in web UI,
# can be true, false or an integer number of lines to save, default *false*
# :pool - use the given Redis connection pool to push this type of job to a given shard.
# pool - use the given Redis connection pool to push this type of job to a given shard.
#
# In practice, any option is allowed. This is the main mechanism to configure the
# options for a specific job.
def sidekiq_options(opts={})
self.sidekiq_options_hash = get_sidekiq_options.merge(opts.stringify_keys)
end