|
|
@ -26,6 +26,7 @@ type (
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// A ServiceGroup is a group of services.
|
|
|
|
// A ServiceGroup is a group of services.
|
|
|
|
|
|
|
|
// Attention: the starting order of the added services is not guaranteed.
|
|
|
|
ServiceGroup struct {
|
|
|
|
ServiceGroup struct {
|
|
|
|
services []Service
|
|
|
|
services []Service
|
|
|
|
stopOnce func()
|
|
|
|
stopOnce func()
|
|
|
@ -41,7 +42,8 @@ func NewServiceGroup() *ServiceGroup {
|
|
|
|
|
|
|
|
|
|
|
|
// Add adds service into sg.
|
|
|
|
// Add adds service into sg.
|
|
|
|
func (sg *ServiceGroup) Add(service Service) {
|
|
|
|
func (sg *ServiceGroup) Add(service Service) {
|
|
|
|
sg.services = append(sg.services, service)
|
|
|
|
// push front, stop with reverse order.
|
|
|
|
|
|
|
|
sg.services = append([]Service{service}, sg.services...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Start starts the ServiceGroup.
|
|
|
|
// Start starts the ServiceGroup.
|
|
|
|