Class: Airbrush::Client

Inherits:
Object show all
Defined in:
lib/airbrush/client.rb

Constant Summary collapse

DEFAULT_INCOMING_QUEUE =
'airbrush_incoming_queue'
DEFAULT_RESPONSE_TIMEOUT =
2.minutes
DEFAULT_QUEUE_VALIDITY =

10.minutes for the moment

0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, incoming_queue = DEFAULT_INCOMING_QUEUE, response_timeout = DEFAULT_RESPONSE_TIMEOUT, queue_validity = DEFAULT_QUEUE_VALIDITY) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
20
21
# File 'lib/airbrush/client.rb', line 15

def initialize(host, incoming_queue = DEFAULT_INCOMING_QUEUE, response_timeout = DEFAULT_RESPONSE_TIMEOUT, queue_validity = DEFAULT_QUEUE_VALIDITY)
  @host = host
  @server = Starling.new(@host)
  @incoming_queue = incoming_queue
  @response_timeout = response_timeout
  @queue_validity = queue_validity.to_i
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



13
14
15
# File 'lib/airbrush/client.rb', line 13

def host
  @host
end

#incoming_queueObject (readonly)

Returns the value of attribute incoming_queue.



13
14
15
# File 'lib/airbrush/client.rb', line 13

def incoming_queue
  @incoming_queue
end

#queue_validityObject (readonly)

Returns the value of attribute queue_validity.



13
14
15
# File 'lib/airbrush/client.rb', line 13

def queue_validity
  @queue_validity
end

#response_timeoutObject (readonly)

Returns the value of attribute response_timeout.



13
14
15
# File 'lib/airbrush/client.rb', line 13

def response_timeout
  @response_timeout
end

Instance Method Details

#process(id, command, args = {}) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/airbrush/client.rb', line 23

def process(id, command, args = {})
  raise 'No job id specified' unless id
  raise 'No command specified' unless command
  raise "Invalid arguments #{args}" unless args.is_a? Hash

  send_and_receive(id, command, args)
end