2022-06-28 14:05:08 +00:00
|
|
|
package mode
|
|
|
|
|
|
|
|
// Mode represents enumeration of Shard work modes.
|
|
|
|
type Mode uint32
|
|
|
|
|
2022-06-29 11:27:36 +00:00
|
|
|
// ReadWrite is a Mode value for shard that is available
|
|
|
|
// for read and write operations. Default shard mode.
|
|
|
|
const ReadWrite Mode = 0
|
2022-06-28 14:05:08 +00:00
|
|
|
|
2022-06-29 11:27:36 +00:00
|
|
|
const (
|
2022-06-28 14:05:08 +00:00
|
|
|
// ReadOnly is a Mode value for shard that does not
|
|
|
|
// accept write operation but is readable.
|
2022-06-29 11:27:36 +00:00
|
|
|
ReadOnly Mode = 1 << iota
|
2022-06-28 14:05:08 +00:00
|
|
|
|
|
|
|
// Degraded is a Mode value for shard that is set automatically
|
|
|
|
// after a certain number of errors is encountered. It is the same as
|
|
|
|
// `mode.ReadOnly` but also enables fallback algorithms for getting object
|
|
|
|
// in case metabase is corrupted.
|
|
|
|
Degraded
|
|
|
|
)
|
|
|
|
|
|
|
|
func (m Mode) String() string {
|
|
|
|
switch m {
|
|
|
|
default:
|
|
|
|
return "UNDEFINED"
|
|
|
|
case ReadWrite:
|
|
|
|
return "READ_WRITE"
|
|
|
|
case ReadOnly:
|
|
|
|
return "READ_ONLY"
|
|
|
|
case Degraded:
|
|
|
|
return "DEGRADED"
|
|
|
|
}
|
|
|
|
}
|
2022-06-29 11:27:36 +00:00
|
|
|
|
|
|
|
// NoMetabase returns true iff m is operating without the metabase.
|
|
|
|
func (m Mode) NoMetabase() bool {
|
|
|
|
return m&Degraded != 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReadOnly returns true iff m prohibits modifying operations with shard.
|
|
|
|
func (m Mode) ReadOnly() bool {
|
|
|
|
return m&ReadOnly != 0
|
|
|
|
}
|