Class: Workling::Clients::BrokerBase
- Defined in:
- lib/workling/clients/broker_base.rb
Direct Known Subclasses
AmqpBunnyClient, AmqpClient, AmqpExchangeClient, MemcacheQueueClient, MemoryQueueClient, RudeQClient, SqsClient, XmppClient
Instance Method Summary collapse
-
#close ⇒ Object
Closes the connection to the job broker.
-
#connect ⇒ Object
Opens a connection to the job broker.
-
#dispatch(clazz, method, options = {}) ⇒ Object
Dispatch a job to the client.
-
#request(work_type, arguments) ⇒ Object
Requests a job on the broker.
-
#retrieve(work_uid) ⇒ Object
Gets job results off a job broker.
-
#subscribe(work_type) ⇒ Object
Subscribe to job results in a job broker.
Methods inherited from Base
Instance Method Details
#close ⇒ Object
Closes the connection to the job broker.
58 59 60 |
# File 'lib/workling/clients/broker_base.rb', line 58 def close raise NotImplementedError.new("Implement close() in your client. ") end |
#connect ⇒ Object
Opens a connection to the job broker.
51 52 53 |
# File 'lib/workling/clients/broker_base.rb', line 51 def connect raise NotImplementedError.new("Implement connect() in your client. ") end |
#dispatch(clazz, method, options = {}) ⇒ Object
Dispatch a job to the client. If this client uses a job broker, then this method should submit it, otherwise it should run the job
clazz: Name of the worker class
method: Name of the methods on the worker
options: optional arguments for the job
13 14 15 16 17 |
# File 'lib/workling/clients/broker_base.rb', line 13 def dispatch(clazz, method, = {}) @connected ||= connect request(Workling::Remote.routing.queue_for(clazz, method), ) return nil end |
#request(work_type, arguments) ⇒ Object
Requests a job on the broker.
work_type:
arguments: the argument to the worker method
26 27 28 |
# File 'lib/workling/clients/broker_base.rb', line 26 def request(work_type, arguments) raise NotImplementedError.new("Implement request(work_type, arguments) in your client. ") end |
#retrieve(work_uid) ⇒ Object
Gets job results off a job broker. Returns nil if there are no results.
worker_uid: the uid returned by workling when the work was dispatched
35 36 37 |
# File 'lib/workling/clients/broker_base.rb', line 35 def retrieve(work_uid) raise NotImplementedError.new("Implement retrieve(work_uid) in your client. ") end |
#subscribe(work_type) ⇒ Object
Subscribe to job results in a job broker.
worker_type:
44 45 46 |
# File 'lib/workling/clients/broker_base.rb', line 44 def subscribe(work_type) raise NotImplementedError.new("Implement subscribe(work_type) in your client. ") end |