@ -98,10 +98,6 @@ type Manager struct {
// client.ConnPool.
// client.ConnPool.
connPoolPinger Pinger
connPoolPinger Pinger
// grpcServerTracker is used to balance grpc connections across servers,
// and has callbacks for adding or removing a server.
grpcServerTracker ServerTracker
// serverName has the name of the managers's server. This is used to
// serverName has the name of the managers's server. This is used to
// short-circuit pinging to itself.
// short-circuit pinging to itself.
serverName string
serverName string
@ -123,7 +119,6 @@ type Manager struct {
func ( m * Manager ) AddServer ( s * metadata . Server ) {
func ( m * Manager ) AddServer ( s * metadata . Server ) {
m . listLock . Lock ( )
m . listLock . Lock ( )
defer m . listLock . Unlock ( )
defer m . listLock . Unlock ( )
m . grpcServerTracker . AddServer ( s )
l := m . getServerList ( )
l := m . getServerList ( )
// Check if this server is known
// Check if this server is known
@ -256,11 +251,6 @@ func (m *Manager) CheckServers(fn func(srv *metadata.Server) bool) {
_ = m . checkServers ( fn )
_ = m . checkServers ( fn )
}
}
// Servers returns the current list of servers.
func ( m * Manager ) Servers ( ) [ ] * metadata . Server {
return m . getServerList ( ) . servers
}
// getServerList is a convenience method which hides the locking semantics
// getServerList is a convenience method which hides the locking semantics
// of atomic.Value from the caller.
// of atomic.Value from the caller.
func ( m * Manager ) getServerList ( ) serverList {
func ( m * Manager ) getServerList ( ) serverList {
@ -277,19 +267,15 @@ func (m *Manager) saveServerList(l serverList) {
}
}
// New is the only way to safely create a new Manager struct.
// New is the only way to safely create a new Manager struct.
func New ( logger hclog . Logger , shutdownCh chan struct { } , clusterInfo ManagerSerfCluster , connPoolPinger Pinger , tracker ServerTracker , serverName string ) ( m * Manager ) {
func New ( logger hclog . Logger , shutdownCh chan struct { } , clusterInfo ManagerSerfCluster , connPoolPinger Pinger , serverName string ) ( m * Manager ) {
if logger == nil {
if logger == nil {
logger = hclog . New ( & hclog . LoggerOptions { } )
logger = hclog . New ( & hclog . LoggerOptions { } )
}
}
if tracker == nil {
tracker = NoOpServerTracker { }
}
m = new ( Manager )
m = new ( Manager )
m . logger = logger . Named ( logging . Manager )
m . logger = logger . Named ( logging . Manager )
m . clusterInfo = clusterInfo // can't pass *consul.Client: import cycle
m . clusterInfo = clusterInfo // can't pass *consul.Client: import cycle
m . connPoolPinger = connPoolPinger // can't pass *consul.ConnPool: import cycle
m . connPoolPinger = connPoolPinger // can't pass *consul.ConnPool: import cycle
m . grpcServerTracker = tracker
m . rebalanceTimer = time . NewTimer ( clientRPCMinReuseDuration )
m . rebalanceTimer = time . NewTimer ( clientRPCMinReuseDuration )
m . shutdownCh = shutdownCh
m . shutdownCh = shutdownCh
m . serverName = serverName
m . serverName = serverName
@ -492,7 +478,6 @@ func (m *Manager) reconcileServerList(l *serverList) bool {
func ( m * Manager ) RemoveServer ( s * metadata . Server ) {
func ( m * Manager ) RemoveServer ( s * metadata . Server ) {
m . listLock . Lock ( )
m . listLock . Lock ( )
defer m . listLock . Unlock ( )
defer m . listLock . Unlock ( )
m . grpcServerTracker . RemoveServer ( s )
l := m . getServerList ( )
l := m . getServerList ( )
// Remove the server if known
// Remove the server if known