buildAndPushChildPolicyConfigs builds the final child policy configuration by adding the `targetField` to the base child policy configuration received in RLS LB policy configuration. The `targetField` is set to target and configuration is pushed to the child policy through the BalancerGroup. Caller
(target string, newCfg *lbConfig, ccs *balancer.ClientConnState)
| 454 | // |
| 455 | // Caller must hold lb.stateMu. |
| 456 | func (b *rlsBalancer) buildAndPushChildPolicyConfigs(target string, newCfg *lbConfig, ccs *balancer.ClientConnState) error { |
| 457 | jsonTarget, err := json.Marshal(target) |
| 458 | if err != nil { |
| 459 | return fmt.Errorf("failed to marshal child policy target %q: %v", target, err) |
| 460 | } |
| 461 | |
| 462 | config := newCfg.childPolicyConfig |
| 463 | targetField := newCfg.childPolicyTargetField |
| 464 | config[targetField] = jsonTarget |
| 465 | jsonCfg, err := json.Marshal(config) |
| 466 | if err != nil { |
| 467 | return fmt.Errorf("failed to marshal child policy config %+v: %v", config, err) |
| 468 | } |
| 469 | |
| 470 | parser, _ := b.childPolicyBuilder.(balancer.ConfigParser) |
| 471 | parsedCfg, err := parser.ParseConfig(jsonCfg) |
| 472 | if err != nil { |
| 473 | return fmt.Errorf("childPolicy config parsing failed: %v", err) |
| 474 | } |
| 475 | |
| 476 | state := balancer.ClientConnState{ResolverState: ccs.ResolverState, BalancerConfig: parsedCfg} |
| 477 | b.logger.Infof("Pushing new state to child policy %q: %+v", target, state) |
| 478 | if err := b.bg.UpdateClientConnState(target, state); err != nil { |
| 479 | b.logger.Warningf("UpdateClientConnState(%q, %+v) failed : %v", target, ccs, err) |
| 480 | } |
| 481 | return nil |
| 482 | } |
| 483 | |
| 484 | func (b *rlsBalancer) ResolverError(err error) { |
| 485 | b.bg.ResolverError(err) |
no test coverage detected