Пример #1
0
        public Task RunCompose(StartJobRequest request, int jobId)
        {
            JobDescription jobDescription = CreateJobDescription(request, jobId);

            return(Task.Run(() =>
            {
                using (IServiceScope scope = _serviceProvider.CreateScope())
                {
                    List <Task <HttpResponseMessage> > calls = new List <Task <HttpResponseMessage> >();
                    foreach (Endpoint endpoint in _composerSettings.Value.Endpoints)
                    {
                        for (int i = 0; i < endpoint.Concurrency; i++)
                        {
                            calls.Add(CallEndpoint(endpoint, jobDescription));
                        }

                        Task.WaitAll(calls.ToArray());

                        IJobService jobService = scope.ServiceProvider.GetService <IJobService>();

                        // Set the entire job as completed
                        jobService.MarkJobAsComplete(jobId);

                        IQueues queues = scope.ServiceProvider.GetService <IQueues>();

                        queues.DeleteQueue(jobId);
                    }
                }
            }));
        }