Class: Workling::Invokers::Base
- Inherits:
-
Object
- Object
- Workling::Invokers::Base
- Defined in:
- lib/workling/invokers/base.rb
Direct Known Subclasses
AmqpSingleSubscriber, BasicPoller, EventmachineSubscriber, LoopedSubscriber, ThreadPoolPoller, ThreadedPoller
Instance Attribute Summary collapse
-
#reset_time ⇒ Object
Returns the value of attribute reset_time.
-
#sleep_time ⇒ Object
Returns the value of attribute sleep_time.
Instance Method Summary collapse
-
#initialize(routing, client_class) ⇒ Base
constructor
call up with super in the subclass constructor.
-
#listen ⇒ Object
Starts main Invoker Loop.
-
#logger ⇒ Object
returns the Workling::Base.logger.
-
#run(type, args) ⇒ Object
Runs the worker method, given.
-
#stop ⇒ Object
Gracefully stops the Invoker.
Constructor Details
#initialize(routing, client_class) ⇒ Base
call up with super in the subclass constructor.
22 23 24 25 26 27 28 |
# File 'lib/workling/invokers/base.rb', line 22 def initialize(routing, client_class) @routing = routing @client_class = client_class @sleep_time = Workling.config[:sleep_time] || 2 @reset_time = Workling.config[:reset_time] || 30 @@mutex ||= Mutex.new end |
Instance Attribute Details
#reset_time ⇒ Object
Returns the value of attribute reset_time.
17 18 19 |
# File 'lib/workling/invokers/base.rb', line 17 def reset_time @reset_time end |
#sleep_time ⇒ Object
Returns the value of attribute sleep_time.
17 18 19 |
# File 'lib/workling/invokers/base.rb', line 17 def sleep_time @sleep_time end |
Instance Method Details
#listen ⇒ Object
Starts main Invoker Loop. The invoker runs until stop() is called.
33 34 35 |
# File 'lib/workling/invokers/base.rb', line 33 def listen raise NotImplementedError.new("Implement listen() in your Invoker. ") end |
#logger ⇒ Object
returns the Workling::Base.logger
58 |
# File 'lib/workling/invokers/base.rb', line 58 def logger; Workling::Base.logger; end |
#run(type, args) ⇒ Object
Runs the worker method, given
type: the worker route
args: the arguments to be passed into the worker method.
51 52 53 54 55 |
# File 'lib/workling/invokers/base.rb', line 51 def run(type, args) worker = @routing[type] method = @routing.method_name(type) worker.dispatch_to_worker_method(method, args) end |
#stop ⇒ Object
Gracefully stops the Invoker. The currently executing Jobs should be allowed
to finish.
41 42 43 |
# File 'lib/workling/invokers/base.rb', line 41 def stop raise NotImplementedError.new("Implement stop() in your Invoker. ") end |