mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
chore: reverse the order of stopping services (#1159)
* chore: reverse the order of stopping services * chore: reverse the order of stopping services
This commit is contained in:
parent
ca72241fa3
commit
7109d6d635
@ -26,6 +26,7 @@ type (
|
||||
}
|
||||
|
||||
// A ServiceGroup is a group of services.
|
||||
// Attention: the starting order of the added services is not guaranteed.
|
||||
ServiceGroup struct {
|
||||
services []Service
|
||||
stopOnce func()
|
||||
@ -41,7 +42,8 @@ func NewServiceGroup() *ServiceGroup {
|
||||
|
||||
// Add adds service into sg.
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user