Browse Source

libnetwork/diagnostic: drop Init method

Fold it into the constructor, because that's what the constructor is
supposed to do.

Signed-off-by: Cory Snider <csnider@mirantis.com>
Cory Snider 1 year ago
parent
commit
757a004a90

+ 0 - 1
libnetwork/cmd/networkdb-test/dbserver/ndbServer.go

@@ -52,7 +52,6 @@ func Server(args []string) {
 	log.G(context.TODO()).Infof("%s uses IP %s\n", localNodeName, ipAddr)
 	log.G(context.TODO()).Infof("%s uses IP %s\n", localNodeName, ipAddr)
 
 
 	server = diagnostic.New()
 	server = diagnostic.New()
-	server.Init()
 	conf := networkdb.DefaultConfig()
 	conf := networkdb.DefaultConfig()
 	conf.Hostname = localNodeName
 	conf.Hostname = localNodeName
 	conf.AdvertiseAddr = ipAddr
 	conf.AdvertiseAddr = ipAddr

+ 0 - 1
libnetwork/controller.go

@@ -115,7 +115,6 @@ func New(cfgOptions ...config.Option) (*Controller, error) {
 		networkLocker:    locker.New(),
 		networkLocker:    locker.New(),
 		DiagnosticServer: diagnostic.New(),
 		DiagnosticServer: diagnostic.New(),
 	}
 	}
-	c.DiagnosticServer.Init()
 
 
 	if err := c.initStores(); err != nil {
 	if err := c.initStores(); err != nil {
 		return nil, err
 		return nil, err

+ 3 - 8
libnetwork/diagnostic/server.go

@@ -49,17 +49,12 @@ type Server struct {
 
 
 // New creates a new diagnostic server
 // New creates a new diagnostic server
 func New() *Server {
 func New() *Server {
-	return &Server{
+	s := &Server{
+		mux:               http.NewServeMux(),
 		registeredHanders: make(map[string]bool),
 		registeredHanders: make(map[string]bool),
 	}
 	}
-}
-
-// Init initialize the mux for the http handling and register the base hooks
-func (s *Server) Init() {
-	s.mux = http.NewServeMux()
-
-	// Register local handlers
 	s.RegisterHandler(s, diagPaths2Func)
 	s.RegisterHandler(s, diagPaths2Func)
+	return s
 }
 }
 
 
 // RegisterHandler allows to register new handlers to the mux and to a specific path
 // RegisterHandler allows to register new handlers to the mux and to a specific path