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
Sean Chittenden 9 years ago
parent e932e9a435
commit 18f7befba9

@ -118,7 +118,7 @@ func NewClient(config *Config) (*Client, error) {
shutdownCh: make(chan struct{}), 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 // Start consulServers maintenance
go c.serverMgr.Start() go c.serverMgr.Start()

@ -176,9 +176,8 @@ func (sm *ServerManager) getServerConfig() serverConfig {
return sm.serverConfigValue.Load().(serverConfig) return sm.serverConfigValue.Load().(serverConfig)
} }
// NewServerManager is the only way to safely create a new ServerManager // New is the only way to safely create a new ServerManager struct.
// struct. func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) {
func NewServerManager(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) {
// NOTE(sean@): Can't pass *consul.Client due to an import cycle // NOTE(sean@): Can't pass *consul.Client due to an import cycle
sm = new(ServerManager) sm = new(ServerManager)
sm.logger = logger sm.logger = logger

@ -32,7 +32,7 @@ func (s *fauxSerf) NumNodes() int {
func testServerManager() (sm *ServerManager) { func testServerManager() (sm *ServerManager) {
logger := GetBufferedLogger() logger := GetBufferedLogger()
shutdownCh := make(chan struct{}) shutdownCh := make(chan struct{})
sm = NewServerManager(logger, shutdownCh, &fauxSerf{}) sm = New(logger, shutdownCh, &fauxSerf{})
return sm return sm
} }
@ -101,8 +101,8 @@ func TestServerManagerInternal_getServerConfig(t *testing.T) {
} }
} }
// func NewServerManager(logger *log.Logger, shutdownCh chan struct{}) (sm *ServerManager) { // func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ConsulClusterInfo) (sm *ServerManager) {
func TestServerManagerInternal_NewServerManager(t *testing.T) { func TestServerManagerInternal_New(t *testing.T) {
sm := testServerManager() sm := testServerManager()
if sm == nil { if sm == nil {
t.Fatalf("ServerManager nil") t.Fatalf("ServerManager nil")

@ -23,16 +23,19 @@ func GetBufferedLogger() *log.Logger {
return localLogger return localLogger
} }
func makeMockServerManager() (sm *server_manager.ServerManager) { type fauxSerf struct {
logger, shutdownCh := mockServerManager() }
sm = server_manager.NewServerManager(logger, shutdownCh, nil)
return sm func (s *fauxSerf) NumNodes() int {
return 16384
} }
func mockServerManager() (logger *log.Logger, shutdownCh chan struct{}) { func testServerManager() (sm *server_manager.ServerManager) {
logger = GetBufferedLogger() logger := GetBufferedLogger()
shutdownCh = make(chan struct{}) logger = log.New(os.Stderr, "", log.LstdFlags)
return logger, shutdownCh shutdownCh := make(chan struct{})
sm = server_manager.New(logger, shutdownCh, &fauxSerf{})
return sm
} }
// func (sm *ServerManager) AddServer(server *server_details.ServerDetails) { // func (sm *ServerManager) AddServer(server *server_details.ServerDetails) {

Loading…
Cancel
Save