Class: Workling::Clients::BrokerBase

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

Instance Method Summary collapse

Methods inherited from Base

installed?, load, #logger

Instance Method Details

#closeObject

Closes the connection to the job broker.

Raises:

  • (NotImplementedError)


58
59
60
# File 'lib/workling/clients/broker_base.rb', line 58

def close
  raise NotImplementedError.new("Implement close() in your client. ")
end

#connectObject

Opens a connection to the job broker.

Raises:

  • (NotImplementedError)


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, options = {})
  @connected ||= connect
  request(Workling::Remote.routing.queue_for(clazz, method), options)
  return nil
end

#request(work_type, arguments) ⇒ Object

Requests a job on the broker.

work_type: 
arguments: the argument to the worker method

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


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:

Raises:

  • (NotImplementedError)


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