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

Function registerBlockingBalancer

stats/opentelemetry/e2e_test.go:1448–1468  ·  view source on GitHub ↗

registerBlockingBalancer registers a stub balancer that delegates to pick_first. It wraps the ClientConn to intercept state updates and wraps the picker to detect calls to Pick. This guarantees the "Delayed LB pick complete" event is emitted reliably.

(t *testing.T, balancerName string)

Source from the content-addressed store, hash-verified

1446// the picker to detect calls to Pick. This guarantees the "Delayed LB pick
1447// complete" event is emitted reliably.
1448func registerBlockingBalancer(t *testing.T, balancerName string) {
1449 t.Helper()
1450 stub.Register(balancerName, stub.BalancerFuncs{
1451 Init: func(bd *stub.BalancerData) {
1452 cc := &testCCWrapper{
1453 ClientConn: bd.ClientConn,
1454 pickInvoked: grpcsync.NewEvent(),
1455 }
1456 bd.ChildBalancer = balancer.Get(pickfirst.Name).Build(cc, bd.BuildOptions)
1457 },
1458 Close: func(bd *stub.BalancerData) {
1459 bd.ChildBalancer.Close()
1460 },
1461 UpdateClientConnState: func(bd *stub.BalancerData, ccs balancer.ClientConnState) error {
1462 return bd.ChildBalancer.UpdateClientConnState(ccs)
1463 },
1464 ExitIdle: func(bd *stub.BalancerData) {
1465 bd.ChildBalancer.ExitIdle()
1466 },
1467 })
1468}
1469
1470// TestTraceSpan_WithRetriesAndNameResolutionDelay verifies that
1471// "Delayed name resolution complete" event is recorded in the call trace span

Calls 7

RegisterFunction · 0.92
NewEventFunction · 0.92
GetFunction · 0.92
BuildMethod · 0.65
CloseMethod · 0.65
UpdateClientConnStateMethod · 0.65
ExitIdleMethod · 0.65

Tested by

no test coverage detected