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

Method Build

balancer/rls/balancer.go:132–158  ·  view source on GitHub ↗
(cc balancer.ClientConn, opts balancer.BuildOptions)

Source from the content-addressed store, hash-verified

130}
131
132func (rlsBB) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer {
133 lb := &rlsBalancer{
134 closed: grpcsync.NewEvent(),
135 done: grpcsync.NewEvent(),
136 cc: cc,
137 bopts: opts,
138 purgeTicker: dataCachePurgeTicker(),
139 dataCachePurgeHook: dataCachePurgeHook,
140 lbCfg: &lbConfig{},
141 pendingMap: make(map[cacheKey]*backoffState),
142 childPolicies: make(map[string]*childPolicyWrapper),
143 updateCh: buffer.NewUnbounded(),
144 }
145 lb.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[rls-experimental-lb %p] ", lb))
146 lb.dataCache = newDataCache(maxCacheSize, lb.logger, opts.Target.String())
147 metricsRecorder := cc.MetricsRecorder()
148 lb.unregisterMetricHandler = metricsRecorder.RegisterAsyncReporter(lb, cacheEntriesMetric, cacheSizeMetric)
149 lb.bg = balancergroup.New(balancergroup.Options{
150 CC: cc,
151 BuildOpts: opts,
152 StateAggregator: lb,
153 Logger: lb.logger,
154 SubBalancerCloseTimeout: time.Duration(0), // Disable caching of removed child policies
155 })
156 go lb.run()
157 return lb
158}
159
160// rlsBalancer implements the RLS LB policy.
161type rlsBalancer struct {

Callers

nothing calls this directly

Calls 8

runMethod · 0.95
NewEventFunction · 0.92
NewUnboundedFunction · 0.92
NewFunction · 0.92
newDataCacheFunction · 0.85
StringMethod · 0.65
MetricsRecorderMethod · 0.65
RegisterAsyncReporterMethod · 0.65

Tested by

no test coverage detected