Module: Protobuf::Rpc::Server

Included in:
Protobuf::Rpc::Socket::Worker, Zmq::Worker
Defined in:
lib/protobuf/rpc/server.rb

Instance Method Summary collapse

Instance Method Details

#gc_pauseObject



13
14
15
16
17
18
19
# File 'lib/protobuf/rpc/server.rb', line 13

def gc_pause
  ::GC.disable if ::Protobuf.gc_pause_server_request?

  yield

  ::GC.enable if ::Protobuf.gc_pause_server_request?
end

#handle_request(request_data, env_data = {}) ⇒ Object

Invoke the service method dictated by the proto wrapper request object



23
24
25
26
27
28
29
30
31
32
# File 'lib/protobuf/rpc/server.rb', line 23

def handle_request(request_data, env_data = {})
  # Create an env object that holds different parts of the environment and
  # is available to all of the middlewares
  env = Env.new(env_data.merge('encoded_request' => request_data, 'log_signature' => log_signature))

  # Invoke the middleware stack, the last of which is the service dispatcher
  env = Rpc.middleware.call(env)

  env.encoded_response
end

#log_signatureObject



34
35
36
# File 'lib/protobuf/rpc/server.rb', line 34

def log_signature
  @_log_signature ||= "[server-#{self.class.name}]"
end