gRPC Reflection

What is gRPC reflection?

Check this out gRPC Python Server Reflection

Example

Refer to the GitHub reflection example

Module Contents

Server-side

Reference implementation for reflection in gRPC Python.

class grpc_reflection.v1alpha.reflection.ReflectionServicer(service_names, pool=None)[source]

Servicer handling RPCs for service statuses.

ServerReflectionInfo(request_iterator, context)[source]

The reflection service is structured as a bidirectional stream, ensuring all related requests go to a single server.

grpc_reflection.v1alpha.reflection.enable_server_reflection(service_names, server, pool=None)[source]

Enables server reflection on a server.

Parameters:
  • service_names – Iterable of fully-qualified service names available.

  • server – grpc.Server to which reflection service will be added.

  • pool – DescriptorPool object to use (descriptor_pool.Default() if None).

Client-side

Reference implementation for reflection client in gRPC Python.

For usage instructions, see the Python Reflection documentation at doc/python/server_reflection.md.

class grpc_reflection.v1alpha.proto_reflection_descriptor_database.ProtoReflectionDescriptorDatabase(channel)[source]

A container and interface for receiving descriptors from a server’s Reflection service.

ProtoReflectionDescriptorDatabase takes a channel to a server with Reflection service, and provides an interface to retrieve the Reflection information. It implements the DescriptorDatabase interface.

It is typically used to feed a DescriptorPool instance.

Parameters:

channel (Channel) –

get_services()[source]

Get list of full names of the registered services.

Returns:

A list of strings corresponding to the names of the services.

Return type:

Iterable[str]

FindFileByName(name)[source]

Find a file descriptor by file name.

This function implements a DescriptorDatabase interface, and is typically not called directly; prefer using a DescriptorPool instead.

Parameters:

name (str) – The name of the file. Typically this is a relative path ending in “.proto”.

Returns:

A FileDescriptorProto for the file.

Raises:

KeyError – the file was not found.

Return type:

FileDescriptorProto

FindFileContainingSymbol(symbol)[source]

Find the file containing the symbol, and return its file descriptor.

The symbol should be a fully qualified name including the file descriptor’s package and any containing messages. Some examples:

  • “some.package.name.Message”

  • “some.package.name.Message.NestedEnum”

  • “some.package.name.Message.some_field”

This function implements a DescriptorDatabase interface, and is typically not called directly; prefer using a DescriptorPool instead.

Parameters:

symbol (str) – The fully-qualified name of the symbol.

Returns:

FileDescriptorProto for the file containing the symbol.

Raises:

KeyError – the symbol was not found.

Return type:

FileDescriptorProto

FindAllExtensionNumbers(extendee_name)[source]

Find the field numbers used by all known extensions of extendee_name.

This function implements a DescriptorDatabase interface, and is typically not called directly; prefer using a DescriptorPool instead.

Parameters:

extendee_name (str) – fully-qualified name of the extended message type.

Returns:

A list of field numbers used by all known extensions.

Raises:

KeyError – The message type extendee_name was not found.

Return type:

Iterable[int]

FindFileContainingExtension(extendee_name, extension_number)[source]

Find the file which defines an extension for the given message type and field number.

This function implements a DescriptorDatabase interface, and is typically not called directly; prefer using a DescriptorPool instead.

Parameters:
  • extendee_name (str) – fully-qualified name of the extended message type.

  • extension_number (int) – the number of the extension field.

Returns:

FileDescriptorProto for the file containing the extension.

Raises:

KeyError – The message or the extension number were not found.

Return type:

FileDescriptorProto