2017-02-16 18:37:21 +00:00
|
|
|
package consts
|
|
|
|
|
|
|
|
type ReplicationState uint32
|
|
|
|
|
|
|
|
const (
|
2017-09-04 23:38:37 +00:00
|
|
|
_ ReplicationState = iota
|
|
|
|
OldReplicationPrimary
|
|
|
|
OldReplicationSecondary
|
|
|
|
OldReplicationBootstrapping
|
|
|
|
|
|
|
|
ReplicationDisabled ReplicationState = 0
|
|
|
|
ReplicationPerformancePrimary ReplicationState = 1 << iota
|
|
|
|
ReplicationPerformanceSecondary
|
|
|
|
ReplicationBootstrapping
|
|
|
|
ReplicationDRPrimary
|
|
|
|
ReplicationDRSecondary
|
2017-02-16 18:37:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (r ReplicationState) String() string {
|
|
|
|
switch r {
|
2017-09-04 23:38:37 +00:00
|
|
|
case ReplicationPerformanceSecondary:
|
|
|
|
return "perf-secondary"
|
|
|
|
case ReplicationPerformancePrimary:
|
|
|
|
return "perf-primary"
|
|
|
|
case ReplicationBootstrapping:
|
|
|
|
return "bootstrapping"
|
|
|
|
case ReplicationDRPrimary:
|
|
|
|
return "dr-primary"
|
|
|
|
case ReplicationDRSecondary:
|
|
|
|
return "dr-secondary"
|
2017-02-16 18:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return "disabled"
|
|
|
|
}
|
2017-09-04 23:38:37 +00:00
|
|
|
|
|
|
|
func (r ReplicationState) HasState(flag ReplicationState) bool { return r&flag != 0 }
|
|
|
|
func (r *ReplicationState) AddState(flag ReplicationState) { *r |= flag }
|
|
|
|
func (r *ReplicationState) ClearState(flag ReplicationState) { *r &= ^flag }
|
|
|
|
func (r *ReplicationState) ToggleState(flag ReplicationState) { *r ^= flag }
|