ClientConn represents a virtual connection to a conceptual endpoint, to perform RPCs. A ClientConn is free to have zero or more actual connections to the endpoint based on configuration, load, etc. It is also free to determine which actual endpoints to use and may change it every RPC, permitting cl
| 667 | // handshakes. It also handles errors on established connections by |
| 668 | // re-resolving the name and reconnecting. |
| 669 | type ClientConn struct { |
| 670 | ctx context.Context // Initialized using the background context at dial time. |
| 671 | cancel context.CancelFunc // Cancelled on close. |
| 672 | |
| 673 | // The following are initialized at dial time, and are read-only after that. |
| 674 | target string // User's dial target. |
| 675 | parsedTarget resolver.Target // See initParsedTargetAndResolverBuilder(). |
| 676 | authority string // See initAuthority(). |
| 677 | dopts dialOptions // Default and user specified dial options. |
| 678 | channelz *channelz.Channel // Channelz object. |
| 679 | resolverBuilder resolver.Builder // See initParsedTargetAndResolverBuilder(). |
| 680 | idlenessMgr *idle.Manager |
| 681 | metricsRecorderList *istats.MetricsRecorderList |
| 682 | statsHandler stats.Handler |
| 683 | |
| 684 | // The following provide their own synchronization, and therefore don't |
| 685 | // require cc.mu to be held to access them. |
| 686 | csMgr *connectivityStateManager |
| 687 | pickerWrapper *pickerWrapper |
| 688 | safeConfigSelector iresolver.SafeConfigSelector |
| 689 | retryThrottler atomic.Value // Updated from service config. |
| 690 | |
| 691 | // mu protects the following fields. |
| 692 | // TODO: split mu so the same mutex isn't used for everything. |
| 693 | mu sync.RWMutex |
| 694 | resolverWrapper *ccResolverWrapper // Always recreated whenever entering idle to simplify Close. |
| 695 | balancerWrapper *ccBalancerWrapper // Always recreated whenever entering idle to simplify Close. |
| 696 | sc *ServiceConfig // Latest service config received from the resolver. |
| 697 | conns map[*addrConn]struct{} // Set to nil on close. |
| 698 | keepaliveParams keepalive.ClientParameters // May be updated upon receipt of a GoAway. |
| 699 | // firstResolveEvent is used to track whether the name resolver sent us at |
| 700 | // least one update. RPCs block on this event. May be accessed without mu |
| 701 | // if we know we cannot be asked to enter idle mode while accessing it (e.g. |
| 702 | // when the idle manager has already been closed, or if we are already |
| 703 | // entering idle mode). |
| 704 | firstResolveEvent *grpcsync.Event |
| 705 | |
| 706 | lceMu sync.Mutex // protects lastConnectionError |
| 707 | lastConnectionError error |
| 708 | } |
| 709 | |
| 710 | // WaitForStateChange waits until the connectivity.State of ClientConn changes from sourceState or |
| 711 | // ctx expires. A true value is returned in former case and false in latter. |
nothing calls this directly
no outgoing calls
no test coverage detected