LoadBalancingConfig generates load balancing config which can used as part of a ClientConnState update to the RLS LB policy.
()
| 73 | // LoadBalancingConfig generates load balancing config which can used as part of |
| 74 | // a ClientConnState update to the RLS LB policy. |
| 75 | func (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 | } |
nothing calls this directly
no test coverage detected