Why do we need to register reflection service on gRPC server
server-based-reflection is something that you will not need to build your day-to-day gRPC APIs.
This is a special instruction which exposes all the publicly accessible gRPC services on a gRPC server.
What this means essentially is that anyone can request your gRPC server to emit out details of the RPC service methods, request-response structures.
Where is this used?
This is used at places where you want to. dynamically call gRPC APIs. By dynamically I mean, the client does not need to hold the proto data-structures and register the RPC client stub.
- grpCurl - curl gRPC services
- gRPC transcoding - exposing json APIs on gRPC servers
Server reflection is not necessary to run the helloworld example.
The helloworld example is also used as a server reflection example, that's why you see the reflection registering code there.
More about server reflection: Server reflection is a service defined to provides information about publicly-accessible gRPC services on a gRPC server. Tutorial available here: https://github.com/grpc/grpc-go/blob/master/Documentation/server-reflection-tutorial.md