grpc: add service config types and parsing - #2731
Conversation
29c707f to
52589c3
Compare
TAG=agy CONV=5f23221a-0150-4021-ad9c-111618d24771
dfawley
left a comment
There was a problem hiding this comment.
Thanks for the updates. The Duration stuff LGTM; glad we can do this without needing to annotate every instance of the field individually.
f668c82 to
d24c2ef
Compare
| .map(|c| { | ||
| let mut map = serde_json::Map::new(); | ||
| map.insert(c.name.clone(), c.config.clone()); | ||
| serde_json::Value::Object(map) | ||
| }) |
There was a problem hiding this comment.
I believe we want this part to do a bit more -- and during parsing, not afterwards. Here's what we do in Go per config entry:
- Lookup the balancer in the registry; skip entry if doesn't exist
- Call it to parse the config; error all service config parsing if it fails
- Collapse to a single selected policy and its parsed config, not a vec.
It's nice to do this here instead of in the channel, because we have LB policies that have similar "child" fields that will want to do this exact same logic.
There was a problem hiding this comment.
I've added a TODO around this. After looking at it, I'd rather do the 'mechanical' and plumbing stuff in the followup or in a smaller PR and keep this more bare bones. LMK if you think that's ok or if we keep good context by putting it here. It seems straightforward enough but would add additional files to the surface of this PR.
There was a problem hiding this comment.
I don't mind if you want to put the implementation in another PR, but then some of these abstractions I think are just wrong in light of the above, and should be deleted if they aren't updated.
-
ServiceConfigshouldn't have apub fn lb_config().ServiceConfigshould be completely opaque externally (only parsed and passed around). -
The
LoadBalancingConfigSerdefield should ideally (I think) parse a JSON array, but collapse it down to a single value: the first supported policy - it can also be empty if either the field is absent or if it contains no entries that are in the registry.
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
Channelbuilde, passing it to the load balancer tree for utilization, and interactions with the Name Resolver.Notes