mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
global: split Akvorado into 3 services
This commit is contained in:
22
common/daemon/lifecycle.go
Normal file
22
common/daemon/lifecycle.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// lifecycleComponent is the lifecycle part of a component.
|
||||
type lifecycleComponent struct {
|
||||
terminateChannel chan struct{}
|
||||
terminateOnce sync.Once
|
||||
}
|
||||
|
||||
// Terminated will return a channel that will be closed when the daemon
|
||||
// needs to terminate.
|
||||
func (c *lifecycleComponent) Terminated() <-chan struct{} {
|
||||
return c.terminateChannel
|
||||
}
|
||||
|
||||
// Terminate should be called to request termination of a daemon.
|
||||
func (c *lifecycleComponent) Terminate() {
|
||||
c.terminateOnce.Do(func() { close(c.terminateChannel) })
|
||||
}
|
||||
Reference in New Issue
Block a user