Class: Workling::Clients::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/workling/clients/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.installed?Boolean

See if the libraries required for this client are installed

Returns:

  • (Boolean)


24
25
26
# File 'lib/workling/clients/base.rb', line 24

def self.installed?
  true
end

.loadObject

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

#closeObject

Closes the connection to the job broker.

Raises:



84
85
86
# File 'lib/workling/clients/base.rb', line 84

def close
  raise WorklingError.new("This client does not involve a broker.")
end

#connectObject

Opens a connection to the job broker.

Raises:



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

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/workling/clients/base.rb', line 41

def dispatch(clazz, method, options = {})
  raise NotImplementedError.new("Implement dispatch(clazz, method, options) in your client. ")
end

#loggerObject

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

Raises:



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

Raises:



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:

Raises:



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