Class: Workling::Clients::Base
- Inherits:
-
Object
- Object
- Workling::Clients::Base
- Defined in:
- lib/workling/clients/base.rb
Direct Known Subclasses
BackgroundjobClient, BrokerBase, NotClient, NotRemoteClient, SpawnClient, ThreadClient
Class Method Summary collapse
-
.installed? ⇒ Boolean
See if the libraries required for this client are installed.
-
.load ⇒ Object
Load the required libraries, for this client.
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.
-
#logger ⇒ Object
returns the Workling::Base.logger.
-
#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.
Class Method Details
.installed? ⇒ Boolean
See if the libraries required for this client are installed
24 25 26 |
# File 'lib/workling/clients/base.rb', line 24 def self.installed? true end |
.load ⇒ Object
Load the required libraries, for this client
16 17 18 |
# File 'lib/workling/clients/base.rb', line 16 def self.load end |
Instance Method Details
#close ⇒ Object
Closes the connection to the job broker.
84 85 86 |
# File 'lib/workling/clients/base.rb', line 84 def close raise WorklingError.new("This client does not involve a broker.") end |
#connect ⇒ Object
Opens a connection to the job broker.
77 78 79 |
# File 'lib/workling/clients/base.rb', line 77 def connect raise WorklingError.new("This client does not involve a broker.") 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
41 42 43 |
# File 'lib/workling/clients/base.rb', line 41 def dispatch(clazz, method, = {}) raise NotImplementedError.new("Implement dispatch(clazz, method, options) in your client. ") end |
#logger ⇒ Object
returns the Workling::Base.logger
30 |
# File 'lib/workling/clients/base.rb', line 30 def logger; Workling::Base.logger; end |
#request(work_type, arguments) ⇒ Object
Requests a job on the broker.
work_type:
arguments: the argument to the worker method
52 53 54 |
# File 'lib/workling/clients/base.rb', line 52 def request(work_type, arguments) raise WorklingError.new("This client does not involve a broker.") 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
61 62 63 |
# File 'lib/workling/clients/base.rb', line 61 def retrieve(work_uid) raise WorklingError.new("This client does not involve a broker.") end |
#subscribe(work_type) ⇒ Object
Subscribe to job results in a job broker.
worker_type:
70 71 72 |
# File 'lib/workling/clients/base.rb', line 70 def subscribe(work_type) raise WorklingError.new("This client does not involve a broker.") end |