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

Method LoadBalancingConfig

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

LoadBalancingConfig generates load balancing config which can used as part of a ClientConnState update to the RLS LB policy.

()

Source from the content-addressed store, hash-verified

73// LoadBalancingConfig generates load balancing config which can used as part of
74// a ClientConnState update to the RLS LB policy.
75func (c *RLSConfig) LoadBalancingConfig() (serviceconfig.LoadBalancingConfig, error) {
76 m := protojson.MarshalOptions{
77 Multiline: true,
78 Indent: " ",
79 UseProtoNames: true,
80 }
81 routeLookupCfg, err := m.Marshal(c.RouteLookupConfig)
82 if err != nil {
83 return nil, err
84 }
85 childPolicy, err := c.ChildPolicy.MarshalJSON()
86 if err != nil {
87 return nil, err
88 }
89 lbConfigJSON := fmt.Sprintf(`
90{
91 "routeLookupConfig": %s,
92 "routeLookupChannelServiceConfig": %s,
93 "childPolicy": %s,
94 "childPolicyConfigTargetFieldName": %q
95}`, string(routeLookupCfg), c.RouteLookupChannelServiceConfig, string(childPolicy), c.ChildPolicyConfigTargetFieldName)
96
97 builder := balancer.Get("rls_experimental")
98 if builder == nil {
99 return nil, errors.New("balancer builder not found for RLS LB policy")
100 }
101 parser := builder.(balancer.ConfigParser)
102 return parser.ParseConfig([]byte(lbConfigJSON))
103}

Callers

nothing calls this directly

Calls 4

GetFunction · 0.92
MarshalMethod · 0.65
ParseConfigMethod · 0.65
MarshalJSONMethod · 0.45

Tested by

no test coverage detected