In grpc, what is the generated_pool method doing? -
i'm bit confused of autogenerated code in grpc , can't find documentation it.
here's proto file called route_guide.proto
syntax = "proto3"; ... package routeguide; // interface exported server. service routeguide { // simple rpc. // // obtains feature @ given position. // // feature empty name returned if there's no feature @ given // position. rpc getfeature(point) returns (feature) {} ... // points represented latitude-longitude pairs in e7 representation // (degrees multiplied 10**7 , rounded nearest integer). // latitudes should in range +/- 90 degrees , longitude should in // range +/- 180 degrees (inclusive). message point { int32 latitude = 1; int32 longitude = 2; } // latitude-longitude rectangle, represented 2 diagonally opposite ... // feature names @ given point. // // if feature not named, name empty. message feature { // name of feature. string name = 1; // point feature detected. point location = 2; }
if run code,
protoc -i ../../protos --ruby_out=../lib --grpc_out=../lib --plugin=protoc-gen-grpc=`which grpc_ruby_plugin` ../../protos/route_guide.proto
it auto gens code:
# generated protocol buffer compiler. not edit! # source: route_guide.proto require 'google/protobuf' google::protobuf::descriptorpool.generated_pool.build add_message "routeguide.point" optional :latitude, :int32, 1 optional :longitude, :int32, 2 end add_message "routeguide.rectangle" optional :lo, :message, 1, "routeguide.point" optional :hi, :message, 2, "routeguide.point" end add_message "routeguide.feature" optional :name, :string, 1 optional :location, :message, 2, "routeguide.point" end add_message "routeguide.routenote" optional :location, :message, 1, "routeguide.point" optional :message, :string, 2 end add_message "routeguide.routesummary" optional :point_count, :int32, 1 optional :feature_count, :int32, 2 optional :distance, :int32, 3 optional :elapsed_time, :int32, 4 end end module routeguide point = google::protobuf::descriptorpool.generated_pool.lookup("routeguide.point").msgclass rectangle = google::protobuf::descriptorpool.generated_pool.lookup("routeguide.rectangle").msgclass feature = google::protobuf::descriptorpool.generated_pool.lookup("routeguide.feature").msgclass routenote = google::protobuf::descriptorpool.generated_pool.lookup("routeguide.routenote").msgclass routesummary = google::protobuf::descriptorpool.generated_pool.lookup("routeguide.routesummary").msgclass end
what these descriptorpool classes? purpose of class?what file do?
i'm curious line:
google::protobuf::descriptorpool.generated_pool.lookup("routeguide.point").msgclass
Comments
Post a Comment