Class: GrpcKit::Rpcs::Server::RequestResponse

Inherits:
Base
  • Object
show all
Defined in:
lib/grpc_kit/rpcs/request_response.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from GrpcKit::Rpcs::Server::Base

Instance Method Details

#invoke(stream, session) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/grpc_kit/rpcs/request_response.rb', line 31

def invoke(stream, session)
  ss = GrpcKit::Streams::Server.new(stream: stream, protobuf: @config.protobuf, session: session)
  call = GrpcKit::Rpcs::Call.new(stream.headers., @config.method_name, @config.service_name, ss)

  request = ss.recv(last: true)
  resp =
    if @config.interceptor
      @config.interceptor.intercept(request, call) do |req, c|
        @handler.send(@config.ruby_style_method_name, req, c)
      end
    else
      @handler.send(@config.ruby_style_method_name, request, call)
    end

  ss.send_msg(resp, last: true)
end