Exemplo n.º 1
0
        private int GetJobExecutionPriority(string jobKey)
        {
            var schedule = GetSchedule(jobKey);

            if (schedule == null)
            {
                return(0);
            }

            var jobHistoryEntry         = JobHistory.GetLastJobResult(jobKey);
            var lastSuccessfulExecution = JobHistory.GetLastSuccessfulJobResult(jobKey);

            try
            {
                var executionPriority = schedule.GetExecutionPriority(jobKey, jobHistoryEntry, lastSuccessfulExecution, _clock.GetNow());
                _logger.LogTrace("Execution priority from scheduler for job {jobKey} is {priority}", jobKey, executionPriority);
                return(executionPriority);
            }
            catch (Exception e)
            {
                _logger.LogWarning(e, "Unable to get the execution priority for job {jobKey} from schedule {scheduleType}. Will be retried in next cycle.", jobKey, schedule.GetType());
                return(0);
            }
        }
Exemplo n.º 2
0
 public void JobHistory_WithNoResults_ReturnsNothing()
 {
     _jobHistory.GetLastJobResult(JobKey).Should().BeNull();
     _jobHistory.GetLastSuccessfulJobResult(JobKey).Should().BeNull();
 }