Example #1
0
 public async Task ScheduleAsync(string key, T job, Instant dueTime, bool canInline, CancellationToken ct = default)
 {
     if (dueTime <= Now && canInline && schedulerOptions.ExecuteInline)
     {
         await ExecuteInlineAsync(key, job);
     }
     else
     {
         await schedulerStore.EnqueueScheduledAsync(key, job, dueTime, 0, ct);
     }
 }
Example #2
0
        public async Task ScheduleAsync(string key, T job, Instant dueTime, bool canInline,
                                        CancellationToken ct = default)
        {
            var now = clock.GetCurrentInstant();

            if (dueTime <= now && canInline && schedulerOptions.ExecuteInline)
            {
                if (consumer != null)
                {
                    await consumer.ExecuteInlineAsync(key, job);
                }
            }
            else
            {
                await schedulerStore.EnqueueScheduledAsync(key, job, dueTime, 0, ct);
            }
        }
Example #3
0
        public async Task ExecuteInlineAsync(string key, T job)
        {
            try
            {
                await onSuccess(new List <T> {
                    job
                }, false, default);
            }
            catch (Exception ex)
            {
                log.LogError(ex, "Failed to handle job.");

                var nextTime = clock.GetCurrentInstant().Plus(Duration.FromMinutes(5));

                await schedulerStore.EnqueueScheduledAsync(key, job, nextTime, 1);
            }
        }