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

Function New

internal/balancergroup/balancergroup.go:249–265  ·  view source on GitHub ↗

New creates a new BalancerGroup. Note that the BalancerGroup needs to be started to work.

(opts Options)

Source from the content-addressed store, hash-verified

247// New creates a new BalancerGroup. Note that the BalancerGroup
248// needs to be started to work.
249func New(opts Options) *BalancerGroup {
250 var bc *cache.TimeoutCache
251 if opts.SubBalancerCloseTimeout != time.Duration(0) {
252 bc = cache.NewTimeoutCache(opts.SubBalancerCloseTimeout)
253 }
254
255 return &BalancerGroup{
256 cc: opts.CC,
257 buildOpts: opts.BuildOpts,
258 stateAggregator: opts.StateAggregator,
259 logger: opts.Logger,
260
261 deletedBalancerCache: bc,
262 idToBalancerConfig: make(map[string]*subBalancerWrapper),
263 scToSubBalancer: make(map[balancer.SubConn]*subBalancerWrapper),
264 }
265}
266
267// AddWithClientConn adds a balancer with the given id to the group. The
268// balancer is built with a balancer builder registered with balancerName. The

Calls 1

NewTimeoutCacheFunction · 0.92