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

Function newCCBalancerWrapper

balancer_wrapper.go:84–102  ·  view source on GitHub ↗

newCCBalancerWrapper creates a new balancer wrapper in idle state. The underlying balancer is not created until the updateClientConnState() method is invoked.

(cc *ClientConn)

Source from the content-addressed store, hash-verified

82// underlying balancer is not created until the updateClientConnState() method
83// is invoked.
84func newCCBalancerWrapper(cc *ClientConn) *ccBalancerWrapper {
85 ctx, cancel := context.WithCancel(cc.ctx)
86 ccb := &ccBalancerWrapper{
87 cc: cc,
88 opts: balancer.BuildOptions{
89 DialCreds: cc.dopts.copts.TransportCredentials,
90 CredsBundle: cc.dopts.copts.CredsBundle,
91 Dialer: cc.dopts.copts.Dialer,
92 Authority: cc.authority,
93 CustomUserAgent: cc.dopts.copts.UserAgent,
94 ChannelzParent: cc.channelz,
95 Target: cc.parsedTarget,
96 },
97 serializer: grpcsync.NewCallbackSerializer(ctx),
98 serializerCancel: cancel,
99 }
100 ccb.balancer = gracefulswitch.NewBalancer(ccb, ccb.opts)
101 return ccb
102}
103
104func (ccb *ccBalancerWrapper) MetricsRecorder() stats.MetricsRecorder {
105 return ccb.cc.metricsRecorderList

Callers 1

initIdleStateLockedMethod · 0.85

Calls 2

NewCallbackSerializerFunction · 0.92
NewBalancerFunction · 0.92

Tested by

no test coverage detected