-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
61 lines (46 loc) · 1.4 KB
/
utils.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
package worker
import (
"time"
"github.com/acentswap/abridge/log"
)
var (
maxVerifyLifetime = int64(7 * 24 * 3600)
restIntervalInVerifyJob = 3 * time.Second
maxDoSwapLifetime = int64(7 * 24 * 3600)
restIntervalInDoSwapJob = 10 * time.Second
maxStableLifetime = int64(7 * 24 * 3600)
restIntervalInStableJob = 10 * time.Second
maxReplaceSwapLifetime = int64(7 * 24 * 3600)
restIntervalInReplaceSwapJob = 60 * time.Second
maxPassBigValueLifetime = int64(7 * 24 * 3600)
restIntervalInPassBigValJob = 300 * time.Second
passBigValueTimeRequired = int64(12 * 3600) // seconds
retrySignInterval = 3 * time.Second
)
func now() int64 {
return time.Now().Unix()
}
func logWorker(job, subject string, context ...interface{}) {
log.Info("["+job+"] "+subject, context...)
}
func logWorkerWarn(job, subject string, context ...interface{}) {
log.Warn("["+job+"] "+subject, context...)
}
func logWorkerError(job, subject string, err error, context ...interface{}) {
fields := []interface{}{"err", err}
fields = append(fields, context...)
log.Error("["+job+"] "+subject, fields...)
}
func logWorkerTrace(job, subject string, context ...interface{}) {
log.Trace("["+job+"] "+subject, context...)
}
func getSepTimeInFind(dist int64) int64 {
nowTime := now()
if nowTime > dist {
return nowTime - dist
}
return 0
}
func restInJob(duration time.Duration) {
time.Sleep(duration)
}