-
Notifications
You must be signed in to change notification settings - Fork 24
/
shard_state.go
51 lines (42 loc) · 1.71 KB
/
shard_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
40
41
42
43
44
45
46
47
48
49
50
51
package dagstore
type ShardState byte
const (
// ShardStateNew indicates that a shard has just been registered and is
// about to be processed for activation.
ShardStateNew ShardState = iota
// ShardStateInitializing indicates that the shard is being initialized
// by being fetched from the mount and being indexed.
ShardStateInitializing
// ShardStateAvailable indicates that the shard has been initialized and is
// active for serving queries. There are no active shard readers.
ShardStateAvailable
// ShardStateServing indicates the shard has active readers and thus is
// currently actively serving requests.
ShardStateServing
// ShardStateRecovering indicates that the shard is recovering from an
// errored state. Such recoveries are always initiated by the user through
// DAGStore.RecoverShard().
ShardStateRecovering ShardState = 0x80
// ShardStateErrored indicates that an unexpected error was encountered
// during a shard operation, and therefore the shard needs to be recovered.
ShardStateErrored ShardState = 0xf0
// ShardStateUnknown indicates that it's not possible to determine the state
// of the shard. This state is currently unused, but it's reserved.
ShardStateUnknown ShardState = 0xff
)
func (ss ShardState) String() string {
strs := [...]string{
ShardStateNew: "ShardStateNew",
ShardStateInitializing: "ShardStateInitializing",
ShardStateAvailable: "ShardStateAvailable",
ShardStateServing: "ShardStateServing",
ShardStateRecovering: "ShardStateRecovering",
ShardStateErrored: "ShardStateErrored",
ShardStateUnknown: "ShardStateUnknown",
}
if ss < 0 || int(ss) >= len(strs) {
// safety comes first.
return "__undefined__"
}
return strs[ss]
}