MCPcopy
hub / github.com/grpc/grpc-go / ServiceConfigJSON

Method ServiceConfigJSON

balancer/rls/internal/test/e2e/rls_lb_config.go:43–71  ·  view source on GitHub ↗

ServiceConfigJSON generates service config with a load balancing config corresponding to the RLS LB policy.

()

Source from the content-addressed store, hash-verified

41// ServiceConfigJSON generates service config with a load balancing config
42// corresponding to the RLS LB policy.
43func (c *RLSConfig) ServiceConfigJSON() (string, error) {
44 m := protojson.MarshalOptions{
45 Multiline: true,
46 Indent: " ",
47 UseProtoNames: true,
48 }
49 routeLookupCfg, err := m.Marshal(c.RouteLookupConfig)
50 if err != nil {
51 return "", err
52 }
53 childPolicy, err := c.ChildPolicy.MarshalJSON()
54 if err != nil {
55 return "", err
56 }
57
58 return fmt.Sprintf(`
59{
60 "loadBalancingConfig": [
61 {
62 "rls_experimental": {
63 "routeLookupConfig": %s,
64 "routeLookupChannelServiceConfig": %s,
65 "childPolicy": %s,
66 "childPolicyConfigTargetFieldName": %q
67 }
68 }
69 ]
70}`, string(routeLookupCfg), c.RouteLookupChannelServiceConfig, string(childPolicy), c.ChildPolicyConfigTargetFieldName), nil
71}
72
73// LoadBalancingConfig generates load balancing config which can used as part of
74// a ClientConnState update to the RLS LB policy.

Calls 2

MarshalMethod · 0.65
MarshalJSONMethod · 0.45