1
This commit is contained in:
parent
ccf217b321
commit
46d9c483f2
@ -12,14 +12,14 @@ type taskMgr struct {
|
||||
}
|
||||
|
||||
func (this* taskMgr) Init() {
|
||||
go this.loadWebHookEvent(constant.ORDER_UPDATE_EVENT)
|
||||
go this.loadWebHookEvent(constant.ORDER_UPDATE_EVENT, this.orderUpdatedCb)
|
||||
}
|
||||
|
||||
func (this* taskMgr) UnInit() {
|
||||
|
||||
}
|
||||
|
||||
func (this* taskMgr) loadWebHookEvent(eventName string) {
|
||||
func (this* taskMgr) loadWebHookEvent(eventName string, cb func(ds *f5.DataSet) bool) {
|
||||
var lastSyncIdx = this.getLastIdx(eventName)
|
||||
for true {
|
||||
if lastSyncIdx < 0 {
|
||||
@ -28,15 +28,31 @@ func (this* taskMgr) loadWebHookEvent(eventName string) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
var newLastSyncIdx int64
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.BCEVENT_DB,
|
||||
"SELECT * FROM t_webhook_process_last_idx WHERE idx > ?",
|
||||
"SELECT * FROM t_webhook_process_last_idx WHERE idx > ? LIMIT 1000",
|
||||
[]string{
|
||||
q5.ToString(lastSyncIdx),
|
||||
},
|
||||
func (err error, ds *f5.DataSet) {
|
||||
|
||||
if err == nil {
|
||||
for ds.Next() {
|
||||
idx := q5.ToInt64(ds.GetByName("idx"))
|
||||
if cb(ds) {
|
||||
if idx > newLastSyncIdx {
|
||||
newLastSyncIdx = idx
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
if newLastSyncIdx > lastSyncIdx {
|
||||
lastSyncIdx = newLastSyncIdx
|
||||
this.saveLastIdx(eventName, lastSyncIdx)
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Second * 3)
|
||||
}
|
||||
@ -86,3 +102,7 @@ func (this* taskMgr) saveLastIdx(eventName string, lastIdx int64) bool {
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
func (this* taskMgr) orderUpdatedCb(ds *f5.DataSet) bool {
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user