Skip to content

Implement/service config#2731

Open
nathanielford wants to merge 10 commits into
grpc:masterfrom
nathanielford:implement/ServiceConfig
Open

Implement/service config#2731
nathanielford wants to merge 10 commits into
grpc:masterfrom
nathanielford:implement/ServiceConfig

Conversation

@nathanielford

@nathanielford nathanielford commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Motivation

ServiceConfig requires an internal representation that we can de/serialize.

Solution

This CL implements the ServiceConfig struct and necessary plumbing for de/serialization. In a follow-on CL(s) we will be adding the plumbing to fully utilize the ServiceConfig, including adding the option to the Channel builde, passing it to the load balancer tree for utilization, and interactions with the Name Resolver.

Notes

  • Serde-specific data transfer objects were created so that we weren't exporting foreign types, and giving us options for de/serialization without breaking users going forward.
  • Initially this PR included deserializing stringified u32 types, in concordance with C++ and Java. We may re-implement this going forward, but for now we are forcing the json to have valid raw integers. The concern here is making sure bugs don't arise because macro annotations get missed on edits. We may decide this is stable enough that we don't care, or we may have an internal type (i.e. GrpcU32) like we do with GrpcDuration.

@nathanielford
nathanielford force-pushed the implement/ServiceConfig branch from 29c707f to 52589c3 Compare July 13, 2026 21:32
@nathanielford
nathanielford requested a review from dfawley July 13, 2026 21:43
@nathanielford
nathanielford marked this pull request as ready for review July 13, 2026 21:43
Comment thread grpc/src/client/service_config/json.rs Outdated
Comment thread grpc/src/client/service_config/json.rs Outdated
Comment thread grpc/src/client/service_config/json.rs Outdated
Comment thread grpc/src/client/service_config/json.rs Outdated
Comment thread grpc/src/client/service_config/json.rs Outdated
Comment thread grpc/src/client/service_config/json.rs Outdated
Comment thread grpc/src/client/service_config/mod.rs Outdated
Comment thread grpc/src/client/channel.rs
Comment thread grpc/src/client/channel.rs
Comment thread grpc/src/inmemory/mod.rs Outdated
Comment thread grpc/src/client/service_config/mod.rs Outdated
Comment thread grpc/src/client/service_config/mod.rs Outdated
Comment thread grpc/src/client/service_config/serde.rs Outdated
Comment thread grpc/src/client/service_config/json.rs Outdated

@dfawley dfawley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. The Duration stuff LGTM; glad we can do this without needing to annotate every instance of the field individually.

Comment thread grpc/src/client/service_config/serde.rs Outdated

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub(crate) struct MethodNameSerDe {
pub(crate) service: String,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should literally every field be in an Option<>? Or what is the failure mode supposed to be if a single field fails to parse?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If deserialization fails, it should return an Error, which will be bubbled up appropriately. Probably better to fail here directly I think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I looked at everything, and I think this the only problem. It is valid to have a fully empty method_config.name. See this example:

https://github.com/grpc/grpc-proto/blob/99135b19189588fcc787acb84cff27991787473d/grpc/service_config/service_config.proto#L58

However, if service is unset, then we must validate that method is also unset.

Comment thread grpc/src/client/service_config/serde.rs Outdated
@nathanielford
nathanielford force-pushed the implement/ServiceConfig branch from f668c82 to d24c2ef Compare July 23, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants