-
Notifications
You must be signed in to change notification settings - Fork 921
/
dshardorchestrator.go
70 lines (56 loc) · 1.01 KB
/
dshardorchestrator.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package dshardorchestrator
import (
"log"
)
type ShardMigrationMode int
const (
ShardMigrationModeNone ShardMigrationMode = iota
ShardMigrationModeTo
ShardMigrationModeFrom
)
type LogLevel int
const (
LogError LogLevel = iota
LogWarning
LogInfo
LogDebug
)
type Logger interface {
Log(level LogLevel, message string)
}
var StdLogInstance = &StdLogger{Level: LogInfo}
type StdLogger struct {
Level LogLevel
Prefix string
}
func (stdl *StdLogger) Log(level LogLevel, message string) {
if stdl.Level < level {
return
}
strLevel := ""
switch level {
case LogError:
strLevel = "ERRO"
case LogWarning:
strLevel = "WARN"
case LogInfo:
strLevel = "INFO"
case LogDebug:
strLevel = "DEBG"
}
log.Printf("[%s] %s%s", strLevel, stdl.Prefix, message)
}
func ContainsInt(slice []int, i int) bool {
for _, v := range slice {
if v == i {
return true
}
}
return false
}
// ShardInfo represents basic shard session info
type ShardInfo struct {
ShardID int
SessionID string
Sequence int64
}