public static async Task <SchedService> FromScheduler(Sched sched) { try { var ctx = sched.CreateContext(); var s = new SchedService { IpAddrs = ServerInfo.IPStrs, Enabled = sched.Enabled, StartTimestamp = sched.PerformTimestamp, ExecuteInterval = (long)sched.Interval.TotalSeconds, PerformInterval = (long)sched.PerformSpan.TotalSeconds, CurrRound = ctx.CurrRound, CurrState = await ctx.GetCurrentStatus(), }; return(s); } catch { } return(null); }
public PerformContext(Sched scheduler, DateTime time) { Master = scheduler; TimeStart = time.ToUniversalTime(); CurrRound = scheduler.GetRound(time); CurrRoundKey = scheduler.GetRoundKey(time); LastRoundKey = scheduler.GetRoundKey(time, -1); RedisKeyStatus = Master.GetNameKey("perform_status"); RedisKeyTimeCost = Master.GetNameKey("perform_timecost"); RedisKeyLog = Master.GetNameKey("perform_log"); RedisKeyAlive = Master.GetNameKey("perform_alive"); RedisKeyRoundLog = Master.GetRoundKey(0, "log"); RedisKeyRoundLock = Master.GetRoundKey(0, "lock"); TimeCTXCreated = DateTime.UtcNow; TimeCTXClaimed = TimeCTXCreated; }