Пример #1
0
        public static async Task EnqueueBatch <TItem>(this IDelayedJobQueue <TItem> delayedQueue,
                                                      IEnumerable <TItem> items, TimeSpan delay) where TItem : IJobStep
        {
            var steps = items.Select(item => new Tuple <TItem, TimeSpan>(item, delay)).ToList();

            await delayedQueue.EnqueueBatch(steps);
        }
Пример #2
0
        public void Initialize(JobData jobData, NebulaContext nebulaContext)
        {
            if (jobData == null)
            {
                throw new ArgumentNullException(nameof(jobData), ErrorKeys.ParameterNull);
            }

            if (nebulaContext == null)
            {
                throw new ArgumentNullException(nameof(nebulaContext), ErrorKeys.ParameterNull);
            }

            _jobId    = jobData.JobId;
            _jobQueue = nebulaContext.JobStepSourceBuilder.BuildDelayedJobQueue <HttpPushOutgoingQueueStep>(_jobId);
            var parametersString = jobData.Configuration?.Parameters;

            if (string.IsNullOrWhiteSpace(parametersString))
            {
                throw new ArgumentNullException(nameof(jobData.Configuration.Parameters), ErrorKeys.ParameterNull);
            }

            _parameters = JsonConvert.DeserializeObject <HttpPushOutgoingQueueParameters>(parametersString);
        }
Пример #3
0
 public static async Task Enqueue <TItem>(this IDelayedJobQueue <TItem> delayedQueue, TItem item,
                                          TimeSpan delay) where TItem : IJobStep
 {
     var step = new Tuple <TItem, TimeSpan>(item, delay);
     await delayedQueue.EnqueueBatch(step.Yield());
 }
Пример #4
0
 public static async Task Enqueue <TItem>(this IDelayedJobQueue <TItem> delayedQueue, TItem item,
                                          DateTime processTime) where TItem : IJobStep
 {
     var step = new Tuple <TItem, DateTime>(item, processTime);
     await delayedQueue.EnqueueBatch(step.Yield());
 }