Class: Protobuf::Rpc::Puma::App

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/protobuf/rpc/puma/app.rb

Instance Method Summary collapse

Instance Method Details

#call(env, socket) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/protobuf/rpc/puma/app.rb', line 8

def call(env, socket)
  req = socket.read(socket.gets('-').to_i)
  if req
    env = Protobuf::Rpc::Env.new(env.merge!('encoded_request' => req, 'log_signature' => log_signature))
    env = Protobuf::Rpc.middleware.call(env)
    res = env.encoded_response

    buffer = Protobuf::Rpc::Buffer.new(:write)
    buffer.set_data(res)
    socket.send(buffer.write, 0)
  end
end