本文整理汇总了Golang中github.com/badoo/thunder/db.LazyTrx.AddCommitCallback方法的典型用法代码示例。如果您正苦于以下问题:Golang LazyTrx.AddCommitCallback方法的具体用法?Golang LazyTrx.AddCommitCallback怎么用?Golang LazyTrx.AddCommitCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/badoo/thunder/db.LazyTrx
的用法示例。
在下文中一共展示了LazyTrx.AddCommitCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: generateJobs
// haveTTRows must be nil if there are no timetable entries for any location
// otherwise it must have only true entries like map["location"] => true
// probably jobs generation can be simplified, it is just the way it is
func generateJobs(tx *db.LazyTrx, className string, settings *ScriptSettings, jiRows map[string]*JobInfoEntry, haveTTRows map[string]bool, flags *FlagEntry) (add_to_timetable []*TimetableEntry, err error) {
if haveTTRows != nil && len(haveTTRows) == 0 {
haveTTRows = nil
}
now := time.Now().Unix()
add_to_timetable = make([]*TimetableEntry, 0)
add_job_info := make([]*JobInfoEntry, 0)
set_finish_jobs := make([]string, 0)
set_init_jobs := make([]string, 0)
set_jobs_generated_js := make([]string, 0)
prepare_next_generation := make([]NextGenParams, 0)
have_finish_jobs := settings.jobs.Have_finish_jobs
is_any := (settings.location_type == LOCATION_TYPE_ANY)
is_temporary := settings.jobs.Temporary
temporary_can_run := false
if flags != nil {
if flags.kill_requested_ts.Valid {
is_done := (haveTTRows == nil)
if is_done {
log.Printf("Class %s is done, all is ok", className)
if !flags.killed_ts.Valid {
tx.AddCommitCallback(func() { continueDispatchAfterKill(className) })
if err = setKilledFlag(tx, className); err != nil {
return
}
if err = prepareNextGeneration(tx, have_finish_jobs, className, settings); err != nil {
return
}
}
} else {
log.Printf("Class %s is not done", className)
startKilling(className)
// not the best place to put it, but it works
if err = setMaxFinishedTs(tx, className, flags.kill_request_employee_id.Int64, flags.kill_requested_ts.Int64); err != nil {
return
}
}
return
}
// Stop generating new job generations when we are on pause
if flags.pause_requested_ts.Valid {
is_done := generationFinished(className, haveTTRows, jiRows, settings)
if is_done && !flags.paused_ts.Valid {
if err = setPausedFlag(tx, className); err != nil {
return
}
flags.paused_ts = sql.NullInt64{Int64: now, Valid: true}
}
if !is_any || flags.paused_ts.Valid {
return
}
}
if is_temporary && flags.run_requested_ts.Valid && is_any {
// We accepted run request, which means that we already generated jobs
if flags.run_accepted_ts.Valid {
if generationFinished(className, haveTTRows, jiRows, settings) {
if err = resetRunRequest(tx, className); err != nil {
return
}
if err = prepareNextGeneration(tx, have_finish_jobs, className, settings); err != nil {
return
}
return
}
} else {
if err = setRunAccepted(tx, className); err != nil {
return
}
}
temporary_can_run = true
}
}
if is_temporary && !temporary_can_run || settings.jobs.Type == JOBS_TYPE_NONE {
return
}
locations := make([]string, 0)
if !is_any {
//.........这里部分代码省略.........