Skip to content

Commit

Permalink
implement ListServices()
Browse files Browse the repository at this point in the history
  • Loading branch information
pratheekshasn committed Aug 17, 2023
1 parent bb0c3d2 commit 2fe61e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lv_proto_server_reflection_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,19 @@ namespace grpc_labview
// reflection_service_.get()->AddFileDescriptorProto(serializedProto);
FileDescriptorProto proto;
proto.ParseFromString(serializedProtoStr);
other_pool.BuildFile(proto);
other_pool_file_descriptor = other_pool.BuildFile(proto);
}


Status LVProtoServerReflectionService::ListService(ServerContext* context,
grpc::reflection::v1alpha::ListServiceResponse* response) {

int numServices = other_pool_file_descriptor->service_count();
for (int i = 0; i < numServices; ++i) {
const google::protobuf::ServiceDescriptor* serviceDescriptor = other_pool_file_descriptor->service(i);
services_->push_back(serviceDescriptor->full_name());
}

if (services_ == nullptr) {
return Status(grpc::StatusCode::NOT_FOUND, "Services not found.");
}
Expand Down
1 change: 1 addition & 0 deletions src/lv_proto_server_reflection_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace grpc_labview

const grpc::protobuf::DescriptorPool* descriptor_pool_;
grpc::protobuf::DescriptorPool other_pool;
const grpc::protobuf::FileDescriptor* other_pool_file_descriptor;
std::vector<std::string>* services_;
};
}

0 comments on commit 2fe61e8

Please sign in to comment.