Class: Cod::Service::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/cod/service.rb

Overview

A service client.

Direct Known Subclasses

Beanstalk::Service::Client

Instance Method Summary collapse

Constructor Details

#initialize(server_chan, answer_chan = nil) ⇒ Client

Returns a new instance of Client.



53
54
55
# File 'lib/cod/service.rb', line 53

def initialize(server_chan, answer_chan=nil)
  @server_chan, @answer_chan = server_chan, answer_chan || server_chan
end

Instance Method Details

#call(rq) ⇒ Object



57
58
59
60
# File 'lib/cod/service.rb', line 57

def call(rq)
  @server_chan.put [rq, @answer_chan]
  @answer_chan.get
end

#closeObject



66
67
68
69
# File 'lib/cod/service.rb', line 66

def close
  @server_chan.close
  @answer_chan.close
end

#notify(rq) ⇒ Object



62
63
64
# File 'lib/cod/service.rb', line 62

def notify(rq)
  @server_chan.put [rq, nil]
end