Module: Workling::Remote
- Defined in:
- lib/workling/remote.rb
Class Method Summary collapse
- .client ⇒ Object
-
.generate_uid(clazz, method) ⇒ Object
generates a unique identifier for this particular job.
- .routing ⇒ Object
-
.run(clazz, method, options = {}) ⇒ Object
dispatches to a workling.
Class Method Details
.client ⇒ Object
17 18 19 |
# File 'lib/workling/remote.rb', line 17 def self.client @@client ||= Workling.select_and_build_client end |
.generate_uid(clazz, method) ⇒ Object
generates a unique identifier for this particular job.
22 23 24 25 |
# File 'lib/workling/remote.rb', line 22 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 |
.routing ⇒ Object
11 12 13 |
# File 'lib/workling/remote.rb', line 11 def self.routing @@routing ||= Workling::Routing::ClassAndMethodRouting.new 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.
29 30 31 32 33 34 35 |
# File 'lib/workling/remote.rb', line 29 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. client.dispatch(clazz, method, ) uid end |