Module: Workling::Remote
- Defined in:
- lib/workling/remote.rb,
lib/workling/remote/runners/base.rb,
lib/workling/remote/invokers/base.rb,
lib/workling/remote/runners/spawn_runner.rb,
lib/workling/remote/invokers/basic_poller.rb,
lib/workling/remote/runners/client_runner.rb,
lib/workling/remote/runners/starling_runner.rb,
lib/workling/remote/invokers/threaded_poller.rb,
lib/workling/remote/runners/not_remote_runner.rb,
lib/workling/remote/runners/backgroundjob_runner.rb,
lib/workling/remote/invokers/eventmachine_subscriber.rb
Defined Under Namespace
Class Method Summary collapse
-
.dispatcher ⇒ Object
retrieve the dispatcher or instantiate it using the defaults.
-
.generate_uid(clazz, method) ⇒ Object
generates a unique identifier for this particular job.
-
.run(clazz, method, options = {}) ⇒ Object
dispatches to a workling.
Class Method Details
.dispatcher ⇒ Object
retrieve the dispatcher or instantiate it using the defaults
22 23 24 |
# File 'lib/workling/remote.rb', line 22 def self.dispatcher @@dispatcher ||= Workling.default_runner end |
.generate_uid(clazz, method) ⇒ Object
generates a unique identifier for this particular job.
27 28 29 30 |
# File 'lib/workling/remote.rb', line 27 def self.generate_uid(clazz, method) uid = ::Digest::MD5.hexdigest("#{ clazz }:#{ method }:#{ rand(1 << 64) }:#{ Time.now }") "#{ clazz.to_s.tableize }/#{ method }/#{ uid }".split("/").join(":") end |
.run(clazz, method, options = {}) ⇒ Object
dispatches to a workling. writes the :uid for this work into the options hash, so make sure you pass in a hash if you want write to a return store in your workling.
34 35 36 37 38 39 40 |
# File 'lib/workling/remote.rb', line 34 def self.run(clazz, method, = {}) uid = Workling::Remote.generate_uid(clazz, method) [:uid] = uid if .kind_of?(Hash) && ![:uid] Workling.find(clazz, method) # this line raises a WorklingError if the method does not exist. dispatcher.run(clazz, method, ) uid end |