From 1ef2e437f3fe7818696b348dd64d8d3593f12758 Mon Sep 17 00:00:00 2001 From: Zach Reyes Date: Mon, 15 Apr 2024 17:42:01 -0400 Subject: [PATCH] Moved config init to init function --- .../client/customroundrobin/customroundrobin.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/features/customloadbalancer/client/customroundrobin/customroundrobin.go b/examples/features/customloadbalancer/client/customroundrobin/customroundrobin.go index 12c2d59bfad1..0a28db84db44 100644 --- a/examples/features/customloadbalancer/client/customroundrobin/customroundrobin.go +++ b/examples/features/customloadbalancer/client/customroundrobin/customroundrobin.go @@ -31,8 +31,11 @@ import ( "google.golang.org/grpc/serviceconfig" ) +var gracefulSwitchPickFirst serviceconfig.LoadBalancingConfig + func init() { balancer.Register(customRoundRobinBuilder{}) + gracefulSwitchPickFirst, _ = endpointsharding.ParseConfig(json.RawMessage(endpointsharding.PickFirstConfig)) } const customRRName = "custom_round_robin" @@ -99,7 +102,6 @@ func (crr *customRoundRobin) UpdateClientConnState(state balancer.ClientConnStat // A call to UpdateClientConnState should always produce a new Picker. That // is guaranteed to happen since the aggregator will always call // UpdateChildState in its UpdateClientConnState. - gracefulSwitchPickFirst, _ := endpointsharding.ParseConfig(json.RawMessage(endpointsharding.PickFirstConfig)) return crr.Balancer.UpdateClientConnState(balancer.ClientConnState{ BalancerConfig: gracefulSwitchPickFirst, ResolverState: state.ResolverState,