Class: JobDispatch::Client::SynchronousProxy
- Defined in:
- lib/job_dispatch/client/synchronous_proxy.rb
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
Methods inherited from Proxy
Constructor Details
This class inherits a constructor from JobDispatch::Client::Proxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/job_dispatch/client/synchronous_proxy.rb', line 10 def method_missing(method, *args) job_spec = @client.enqueue(queue: queue, target: @target, method: method.to_s, parameters: args) completed_job = @client.notify(job_spec["job_id"]) if completed_job.nil? raise ProxyError.new("Internal error! There should not be a nil response from the broker.") end result = completed_job["job"] && completed_job["job"]["result"] case completed_job["status"] when "failed" raise ProxyError.new("Job failed: #{result}", completed_job) when "completed" return result else raise ProxyError.new("Notify should not return for a pending or in progress job!") end end |