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.
This commit is contained in:
Sean Chittenden 2016-02-24 22:08:13 -08:00
parent 7faea986a0
commit 9de9cf90f1
4 changed files with 17 additions and 15 deletions

View File

@ -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()

View File

@ -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

View File

@ -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")

View File

@ -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) {