(s Service)
| 27 | } |
| 28 | |
| 29 | func (p *pool) Add(s Service) Lifecycle { |
| 30 | p.mutex.Lock() |
| 31 | if p.running { |
| 32 | panic("bug: pool already running, cannot add service") |
| 33 | } |
| 34 | defer p.mutex.Unlock() |
| 35 | l := p.lifecycleFactory.Make(s) |
| 36 | l.OnStateChange(p.onServiceStateChange) |
| 37 | p.serviceStates[s] = StateStopped |
| 38 | p.services = append(p.services, s) |
| 39 | p.lifecycles[s] = l |
| 40 | return l |
| 41 | } |
| 42 | |
| 43 | func (p *pool) RunWithLifecycle(lifecycle Lifecycle) error { |
| 44 | p.mutex.Lock() |
nothing calls this directly
no test coverage detected