Class: GrpcReflection::Server

Inherits:
Grpc::Reflection::V1::ServerReflection::Service show all
Defined in:
lib/grpc_reflection/server.rb

Instance Method Summary collapse

Instance Method Details

#server_reflection_info(req, _unused_call) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/grpc_reflection/server.rb', line 5

def server_reflection_info(req, _unused_call)
  # TODO: support streaming call
  request = req.first

  res = Grpc::Reflection::V1::ServerReflectionResponse.new
  # TODO: implement another responses
  if request.list_services.size != 0
    res.list_services_response = Grpc::Reflection::V1::ListServiceResponse.new(service: list_services_response)
  elsif !request.file_containing_symbol.empty?
    result = GrpcReflection::FileDescriptorManager.select(request.file_containing_symbol)
    res.file_descriptor_response = Grpc::Reflection::V1::FileDescriptorResponse.new(file_descriptor_proto: result)
  end
  [res].enum_for(:each)
end