This directory contains the implementation of gRPC's service config feature, which allows for per-service and per-method configuration of a gRPC channel.
See also: gRPC Core overview
The code in this directory provides a mechanism for parsing and applying service configs. Service configs can be used to configure a variety of features, such as load balancing, retries, and message size limits.
ServiceConfig: TheServiceConfigclass is an abstract base class for service configs. It provides methods for retrieving the raw JSON string of the service config, as well as for retrieving parsed config values for a given method.ServiceConfigParser: TheServiceConfigParserclass is a registry ofParserinstances. EachParseris responsible for parsing a specific part of the service config. This makes the service config framework highly extensible.
- Create a new class that derives from
ServiceConfigParser::Parser. - Implement the
ParseGlobalParamsand/orParsePerMethodParamsmethods. These methods will be called by theServiceConfigframework to parse the global and per-method parts of the service config, respectively. - Register your parser with the
CoreConfigurationbuilder at startup.
service_config.h: Defines theServiceConfigclass.service_config_parser.h,service_config_parser.cc: These files define theServiceConfigParserclass.service_config_impl.h,service_config_impl.cc: These files define theServiceConfigImplclass, which is the concrete implementation of theServiceConfiginterface.service_config_call_data.h: Defines theServiceConfigCallDataclass, which is used to store the per-call service config data.
- Service configs are typically provided by the name resolver (see
../resolver/AGENTS.md). - Service configs can also be delivered via xDS (see
../xds/AGENTS.md). - The service config is a powerful feature that allows for a great deal of flexibility in configuring gRPC channels.
- The service config is used to configure load balancing (see
../load_balancing/AGENTS.md).