update sleep CronTime
This commit is contained in:
parent
3d32a9a56a
commit
08994c8c42
@ -14,7 +14,7 @@ type M = map[string]interface{}
|
||||
func main() {
|
||||
if len(os.Args) == 1 { // 默认情况下,展示saga例子
|
||||
dtmsvr.PopulateMysql()
|
||||
go dtmsvr.StartSvr()
|
||||
go dtmsvr.Main()
|
||||
go examples.SagaStartSvr()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
examples.SagaFireRequest()
|
||||
@ -23,7 +23,7 @@ func main() {
|
||||
} else if os.Args[1] == "all" { // 运行所有示例
|
||||
dtmsvr.PopulateMysql()
|
||||
examples.PopulateMysql()
|
||||
go dtmsvr.StartSvr()
|
||||
go dtmsvr.Main()
|
||||
go examples.SagaStartSvr()
|
||||
go examples.TccStartSvr()
|
||||
go examples.XaStartSvr()
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package dtmsvr
|
||||
|
||||
type dtmsvrConfig struct {
|
||||
PreparedExpire int64 // 单位秒,处于prepared中的任务,过了这个时间,查询结果还是PENDING的话,则会被cancel
|
||||
JobCronInterval int64 // 单位秒 当事务等待这个时间之后,还没有变化,则进行一轮处理,包括prepared中的任务和commited的任务
|
||||
PreparedExpire uint64 // 单位秒,处于prepared中的任务,过了这个时间,查询结果还是PENDING的话,则会被cancel
|
||||
JobCronInterval uint64 // 单位秒 当事务等待这个时间之后,还没有变化,则进行一轮处理,包括prepared中的任务和commited的任务
|
||||
Mysql map[string]string
|
||||
}
|
||||
|
||||
|
||||
@ -61,6 +61,6 @@ func handlePanic() {
|
||||
|
||||
func sleepCronTime() {
|
||||
delta := math.Min(3, float64(config.JobCronInterval))
|
||||
interval := time.Duration(rand.Float64() * delta * float64(time.Second))
|
||||
interval := time.Duration((float64(config.JobCronInterval) - rand.Float64()*delta) * float64(time.Second))
|
||||
time.Sleep(interval)
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@ var dtmsvrPort = 8080
|
||||
|
||||
func Main() {
|
||||
go StartSvr()
|
||||
go CronCommitted()
|
||||
go CronPrepared()
|
||||
}
|
||||
|
||||
func StartSvr() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user