livery_grpc_reflection (livery_grpc v0.1.0)

View Source

The v1 gRPC server reflection service (grpc.reflection.v1).

Lets tools like grpcurl and Postman discover services and message schemas at runtime, without a local .proto. Enable it by starting the server with reflection => true (see livery_grpc:start_server/1), which mounts this service and feeds it the descriptor set built from every registered service.

ServerReflectionInfo is bidirectional: the client streams requests and this service streams one response each, answering list_services, file_by_filename, and file_containing_symbol. Extensions are a proto2 feature and report empty/not-found.

The served file descriptors come from gpb's descriptor/0 (the descriptor build option), which returns a FileDescriptorSet; this module splits it into the per-file FileDescriptorProto bytes the reflection protocol expects.

Summary

Functions

Build the reflection lookup tables from the server's registrations: the exposed service names, and, keyed by file name and by symbol, the FileDescriptorProto bytes that define them.

The ServerReflectionInfo bidirectional RPC.

The service spec to mount (done for you by reflection => true).

Types

data()

-type data() ::
          #{services := [binary()],
            files := #{binary() => [binary()]},
            symbols := #{binary() => [binary()]}}.

Functions

build(Registrations)

-spec build([livery_grpc_service:registration()]) -> data().

Build the reflection lookup tables from the server's registrations: the exposed service names, and, keyed by file name and by symbol, the FileDescriptorProto bytes that define them.

server_reflection_info(Stream, Ctx)

-spec server_reflection_info(livery_grpc_stream:stream(), livery_grpc_server:ctx()) ->
                                ok | {error, term()}.

The ServerReflectionInfo bidirectional RPC.

service()

-spec service() -> livery_grpc_service:registration().

The service spec to mount (done for you by reflection => true).