-
Notifications
You must be signed in to change notification settings - Fork 1
/
db_state.go
39 lines (33 loc) · 885 Bytes
/
db_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
38
39
package domain
import "fmt"
type WsrepLocalState uint
type WsrepLocalStateComment string
const (
Joining WsrepLocalState = iota + 1 // https://splice.com/blog/iota-elegant-constants-golang/
DonorDesynced
Joined
Synced
JoiningString = WsrepLocalStateComment("Joining")
DonorDesyncedString = WsrepLocalStateComment("Donor/Desynced")
JoinedString = WsrepLocalStateComment("Joined")
SyncedString = WsrepLocalStateComment("Synced")
)
type DBState struct {
WsrepLocalIndex uint
WsrepLocalState WsrepLocalState
ReadOnly bool
}
func (w WsrepLocalState) Comment() WsrepLocalStateComment {
switch w {
case Joining:
return JoiningString
case DonorDesynced:
return DonorDesyncedString
case Joined:
return JoinedString
case Synced:
return SyncedString
default:
return WsrepLocalStateComment(fmt.Sprintf("Unrecognized state: %d", w))
}
}