mirror of https://github.com/hashicorp/consul
Rename NewServerManger to just New
Follow go style recommendations now that this has been refactored out of the consul package and doesn't need the qualifier in the name.pull/1873/head
parent
e932e9a435
commit
18f7befba9
|
@ -118,7 +118,7 @@ func NewClient(config *Config) (*Client, error) {
|
|||
shutdownCh: make(chan struct{}),
|
||||
}
|
||||
|
||||
c.serverMgr = server_manager.NewServerManager(c.logger, c.shutdownCh, c.serf)
|
||||
c.serverMgr = server_manager.New(c.logger, c.shutdownCh, c.serf)
|
||||
|
||||
// Start consulServers maintenance
|
||||
go c.serverMgr.Start()
|
||||
|
|
|
@ -176,9 +176,8 @@ func (sm *ServerManager) getServerConfig() serverConfig {
|
|||
return sm.serverConfigValue.Load().(serverConfig)
|
||||
}
|
||||
|
||||
// NewServerManager is the only way to safely create a new ServerManager
|
||||
// struct.
|
||||
func NewServerManager(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) {
|
||||
// New is the only way to safely create a new ServerManager struct.
|
||||
func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) {
|
||||
// NOTE(sean@): Can't pass *consul.Client due to an import cycle
|
||||
sm = new(ServerManager)
|
||||
sm.logger = logger
|
||||
|
|
|
@ -32,7 +32,7 @@ func (s *fauxSerf) NumNodes() int {
|
|||
func testServerManager() (sm *ServerManager) {
|
||||
logger := GetBufferedLogger()
|
||||
shutdownCh := make(chan struct{})
|
||||
sm = NewServerManager(logger, shutdownCh, &fauxSerf{})
|
||||
sm = New(logger, shutdownCh, &fauxSerf{})
|
||||
return sm
|
||||
}
|
||||
|
||||
|
@ -101,8 +101,8 @@ func TestServerManagerInternal_getServerConfig(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// func NewServerManager(logger *log.Logger, shutdownCh chan struct{}) (sm *ServerManager) {
|
||||
func TestServerManagerInternal_NewServerManager(t *testing.T) {
|
||||
// func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) {
|
||||
func TestServerManagerInternal_New(t *testing.T) {
|
||||
sm := testServerManager()
|
||||
if sm == nil {
|
||||
t.Fatalf("ServerManager nil")
|
||||
|
|
|
@ -23,16 +23,19 @@ func GetBufferedLogger() *log.Logger {
|
|||
return localLogger
|
||||
}
|
||||
|
||||
func makeMockServerManager() (sm *server_manager.ServerManager) {
|
||||
logger, shutdownCh := mockServerManager()
|
||||
sm = server_manager.NewServerManager(logger, shutdownCh, nil)
|
||||
return sm
|
||||
type fauxSerf struct {
|
||||
}
|
||||
|
||||
func mockServerManager() (logger *log.Logger, shutdownCh chan struct{}) {
|
||||
logger = GetBufferedLogger()
|
||||
shutdownCh = make(chan struct{})
|
||||
return logger, shutdownCh
|
||||
func (s *fauxSerf) NumNodes() int {
|
||||
return 16384
|
||||
}
|
||||
|
||||
func testServerManager() (sm *server_manager.ServerManager) {
|
||||
logger := GetBufferedLogger()
|
||||
logger = log.New(os.Stderr, "", log.LstdFlags)
|
||||
shutdownCh := make(chan struct{})
|
||||
sm = server_manager.New(logger, shutdownCh, &fauxSerf{})
|
||||
return sm
|
||||
}
|
||||
|
||||
// func (sm *ServerManager) AddServer(server *server_details.ServerDetails) {
|
||||
|
|
Loading…
Reference in New Issue