本文整理汇总了Golang中github.com/badoo/thunder/db.LazyTrx.Commit方法的典型用法代码示例。如果您正苦于以下问题:Golang LazyTrx.Commit方法的具体用法?Golang LazyTrx.Commit怎么用?Golang LazyTrx.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/badoo/thunder/db.LazyTrx
的用法示例。
在下文中一共展示了LazyTrx.Commit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: doCycle
//.........这里部分代码省略.........
log.Debugf("Load estimates updated for %.5f sec", float64(time.Now().UnixNano()-startTs)/1e9)
func() {
rusageInfo.Lock()
defer rusageInfo.Unlock()
log.Debugf("Group hosts: %+v", rusageInfo.groupHosts)
}()
startTs = time.Now().UnixNano()
failedLocationsMutex.Lock()
failedLocations = make(map[string]bool)
failedLocationsMutex.Unlock()
success := true
if len(scripts) > 0 {
throttle.setIntervalCh <- time.Second / time.Duration(len(scripts))
}
trigger(throttle.c, "throttle, start of cycle")
for className, script := range scripts {
<-throttle.c
tx := new(db.LazyTrx)
err := tx.Begin()
if err != nil {
log.Errorf("Could not start transaction in job generate: %s", err.Error())
success = false
continue
}
have := make(map[string]bool)
locTtRows := classLocTTRows[className]
if locTtRows != nil {
for rawLoc, v := range locTtRows {
loc, err := getLocationIdx(script.settings.location_type, rawLoc)
if err != nil {
log.Warningf("Broken settings for class %s: %s", className, err.Error())
loc = rawLoc
}
if len(v) > 0 {
have[loc] = true
}
}
}
add_to_timetable, err := generateJobs(tx, className, script.settings, jiRows[className], have, flags[className])
if err != nil {
log.Errorf("Could generate jobs for class %s: %s", className, err.Error())
tx.Rollback()
success = false
continue
}
err = tx.Commit()
if err != nil {
log.Errorf("Could not commit generate jobs for class %s: %s", className, err.Error())
success = false
continue
}
per_location := make(map[string][]*TimetableEntry)
for _, row := range add_to_timetable {
allSettingsMutex.Lock()
row.settings = allSettings[row.settings_id]
allSettingsMutex.Unlock()
if row.settings == nil {
log.Warningf("Internal inconsistency error: Invalid settings for generated row: %+v", row)
continue
}
key := DEFAULT_LOCATION_IDX
if row.settings.location_type == LOCATION_TYPE_EACH {
key = row.location
}
if _, ok := per_location[key]; !ok {
per_location[key] = make([]*TimetableEntry, 0)
}
per_location[key] = append(per_location[key], row)
}
for location, rows := range per_location {
notifyAboutNewTTRows(className, location, rows, true)
}
}
notifyForFullTTSelect(classLocTTRows, true)
log.Debugf("Processed %d classes for %.5f sec", len(scripts), float64(time.Now().UnixNano()-startTs)/1e9)
log.Debugf("Total %.5f sec", float64(time.Now().UnixNano()-unifiedStartTs)/1e9)
return success
}