Пример #1
0
        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());
        }
Пример #2
0
        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");
            }
        }
Пример #3
0
        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;
            }
        }
Пример #4
0
 public IScheduler SchedulerFromPriority(SchedulerPriority priority)
 {
     return(_scheduler);
 }
Пример #5
0
 public IScheduler SchedulerFromPriority(SchedulerPriority priority)
 {
     return(this);
 }
Пример #6
0
 /// <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);
 }
Пример #7
0
 /// <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;
 }
Пример #8
0
 /// <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));
 }
Пример #9
0
 /// <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;
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Schedule"/> class.
 /// </summary>
 public Schedule()
 {
     NextTryTime = Clock.Now;
     Priority    = SchedulerPriority.Normal;
 }
Пример #11
0
		public IScheduler SchedulerFromPriority(SchedulerPriority priority)
		{
			return this;
		}