-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.go
37 lines (33 loc) · 870 Bytes
/
state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package goservices
import "fmt"
// State is the state of a service.
// Is it exported to ease the implementation of services.
type State uint8
const (
// StateStopped is the state of a service that is stopped.
StateStopped State = iota
// StateStarting is the state of a service that is starting.
StateStarting
// StateRunning is the state of a service that is running.
StateRunning
// StateStopping is the state of a service that is stopping.
StateStopping
// StateCrashed is the state of a service that has crashed.
StateCrashed
)
func (s State) String() string {
switch s {
case StateStopped:
return "stopped"
case StateStarting:
return "starting"
case StateRunning:
return "running"
case StateStopping:
return "stopping"
case StateCrashed:
return "crashed"
default:
panic(fmt.Sprintf("State %d has no corresponding string", s))
}
}