Class: Juggler
- Inherits:
-
Object
- Object
- Juggler
- Defined in:
- lib/juggler.rb,
lib/juggler/runner.rb,
lib/juggler/job_runner.rb
Defined Under Namespace
Modules: StateMachine Classes: JobRunner, Runner
Class Attribute Summary collapse
-
.backoff_function ⇒ Object
Returns the value of attribute backoff_function.
-
.exception_handler ⇒ Object
Returns the value of attribute exception_handler.
- .logger ⇒ Object
-
.shutdown_grace_timeout ⇒ Object
By default after receiving QUIT juggler will wait up to 2s for running jobs to complete before killing them.
Class Method Summary collapse
-
.juggle(method, concurrency = 1, &strategy) ⇒ Object
Strategy block: should return a deferrable object (so that juggler can apply callbacks and errbacks).
- .server ⇒ Object
- .server=(uri) ⇒ Object
- .throw(method, params, options = {}) ⇒ Object
Class Attribute Details
.backoff_function ⇒ Object
Returns the value of attribute backoff_function.
10 11 12 |
# File 'lib/juggler.rb', line 10 def backoff_function @backoff_function end |
.exception_handler ⇒ Object
Returns the value of attribute exception_handler.
9 10 11 |
# File 'lib/juggler.rb', line 9 def exception_handler @exception_handler end |
.logger ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/juggler.rb', line 26 def logger @logger ||= begin require 'logger' logger = Logger.new(STDOUT) logger.level = Logger::WARN logger.debug("Created logger") logger end end |
.shutdown_grace_timeout ⇒ Object
By default after receiving QUIT juggler will wait up to 2s for running jobs to complete before killing them
22 23 24 |
# File 'lib/juggler.rb', line 22 def shutdown_grace_timeout @shutdown_grace_timeout || 2 end |
Class Method Details
.juggle(method, concurrency = 1, &strategy) ⇒ Object
Strategy block: should return a deferrable object (so that juggler can apply callbacks and errbacks). You should note that this deferrable may be failed by juggler if the job timeout is exceeded, and therefore you are responsible for cleaning up your state (for example cancelling any timers which you have created)
47 48 49 |
# File 'lib/juggler.rb', line 47 def juggle(method, concurrency = 1, &strategy) Runner.new(method, concurrency, strategy).run end |
.server ⇒ Object
16 17 18 |
# File 'lib/juggler.rb', line 16 def server @server ||= URI.parse("beanstalk://localhost:11300") end |
.server=(uri) ⇒ Object
12 13 14 |
# File 'lib/juggler.rb', line 12 def server=(uri) @server = URI.parse(uri) end |
.throw(method, params, options = {}) ⇒ Object
36 37 38 39 40 |
# File 'lib/juggler.rb', line 36 def throw(method, params, = {}) # TODO: Do some checking on the method connection.use(method.to_s) connection.put(Marshal.dump(params), ) end |