Class: Zack::Server

Inherits:
Target show all
Defined in:
lib/zack/server.rb

Overview

Server side for RPC calls.

Instance Attribute Summary collapse

Attributes inherited from Target

#factory, #server

Instance Method Summary collapse

Methods inherited from Target

#process_request, #run

Constructor Details

#initialize(tube_name, opts = {}) ⇒ Server

Returns a new instance of Server.



8
9
10
11
12
13
# File 'lib/zack/server.rb', line 8

def initialize(tube_name, opts={})
  super
    
  channel = Cod.beanstalk(server, tube_name)
  @service = Cod::Service.new(channel)
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



6
7
8
# File 'lib/zack/server.rb', line 6

def service
  @service
end

Instance Method Details

#handle_requestObject

Handles exactly one request.



17
18
19
20
21
# File 'lib/zack/server.rb', line 17

def handle_request
  service.one { |(sym, args)|  
    process_request(sym, args)
  }
end