public async Task <string> EnqueueAsync <TScheduler, TArgs>(TArgs args, SchedulerPriority priority = SchedulerPriority.Normal, TimeSpan?delay = null) where TScheduler : IScheduler <TArgs> { var schedule = new Schedule { SchedulerType = typeof(TScheduler).AssemblyQualifiedName, SchedulerArgs = args.ToJsonString(), Priority = priority }; if (delay.HasValue) { schedule.NextTryTime = Clock.Now.Add(delay.Value); } await _store.InsertAsync(schedule); return(schedule.Id.ToString()); }
public IScheduler SchedulerFromPriority(SchedulerPriority priority) { switch (priority) { case SchedulerPriority.Lowest: case SchedulerPriority.Low: return(_lowScheduler); case SchedulerPriority.Normal: return(_normalScheduler); case SchedulerPriority.High: return(_highScheduler); default: throw new ArgumentOutOfRangeException("priority"); } }
public void Do(SchedulerPriority priority, Action task) { switch (priority) { case SchedulerPriority.High: Do(TimeSpan.MinValue, task); break; case SchedulerPriority.Medium: Do(TimeSpan.FromMilliseconds(100), task); break; case SchedulerPriority.MediumLow: Do(TimeSpan.FromMilliseconds(500), task); break; case SchedulerPriority.Low: Do(TimeSpan.FromMilliseconds(900), task); break; } }
public IScheduler SchedulerFromPriority(SchedulerPriority priority) { return(_scheduler); }
public IScheduler SchedulerFromPriority(SchedulerPriority priority) { return(this); }
/// <summary> /// Returns new schedule options with an updated priority. /// </summary> /// <param name="priority"> /// The new priority. /// </param> /// <returns> /// The new options. /// </returns> public ScheduleOptions WithNewPriority(SchedulerPriority priority) { return new ScheduleOptions(this.UpdateInterval, priority); }
/// <summary> /// Initializes a new <see cref="ScheduleOptions"/> instance. /// </summary> /// <param name="updateInterval"> /// The requested update interval for the subscriber. /// </param> /// <param name="priority"> /// The requested update priority for the subscriber. /// </param> /// <remarks> /// The report interval is specified in milliseconds. /// </remarks> public ScheduleOptions(uint updateInterval, SchedulerPriority priority) { this.UpdateInterval = updateInterval; this.Priority = priority; }
/// <summary> /// Returns new schedule options with an updated priority. /// </summary> /// <param name="priority"> /// The new priority. /// </param> /// <returns> /// The new options. /// </returns> public ScheduleOptions WithNewPriority(SchedulerPriority priority) { return(new ScheduleOptions(this.UpdateInterval, priority)); }
/// <summary> /// Initializes a new instance of the <see cref="Schedule"/> class. /// </summary> public Schedule() { NextTryTime = Clock.Now; Priority = SchedulerPriority.Normal; }
public IScheduler SchedulerFromPriority(SchedulerPriority priority) { return this; }