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