Example #1
0
// New creates a new Service, using the given Router and WebServer.
// If the router has already a configured Cluster, it is registered as a service module.
// The Router and Webserver are then registered as modules.
func New(router router.Router, webserver *webserver.WebServer) *Service {
	s := &Service{
		webserver:       webserver,
		router:          router,
		healthFrequency: defaultHealthFrequency,
		healthThreshold: defaultHealthThreshold,
	}
	cluster := router.Cluster()
	if cluster != nil {
		s.RegisterModules(1, 5, cluster)
		router.Cluster().Router = router
	}
	s.RegisterModules(2, 2, s.router)
	s.RegisterModules(3, 4, s.webserver)
	return s
}