func getNextJobGenerateTs(className string, firstRun bool, prevTs uint64, settings *ScriptSettings) (nextTs uint64) { if !settings.have_next_ts_callback { if firstRun { nextTs = uint64(time.Now().Unix()) } else { nextTs = prevTs + uint64(settings.repeat) } } else if settings.next_ts_callback.Callback == "cron" { if _, ok := settings.next_ts_callback.Settings["cron"]; !ok { log.Warning("'cron' section is absent for next ts callback for " + className) return } now := uint64(time.Now().Unix()) if firstRun { prevTs = now } nextTs = getNextLaunchTsForCron(prevTs, now, rand.Intn(60), settings.next_ts_callback.Settings["cron"]) } else { log.Warning("Callbacks other than cron are not supported for " + className) } return }
func (p *LazyTrx) Commit() error { if p.level == 0 { buf := make([]byte, 5000) n := runtime.Stack(buf, false) log.Warning("Requested commit for zero level: " + string(buf[0:n])) } p.level-- if p.level == 0 && p.tx != nil { err := p.tx.Commit() DebugPrintln(p.Name, "COMMIT") if err != nil { return err } if p.commitCallbacks != nil { for _, cb := range p.commitCallbacks { cb() } } p.tx = nil } return nil }