Ejemplo n.º 1
0
        public IEnumerable <BatchedWorkItem> CreateWorkItems(IWorkBatchFactory workBatchFactory, CancellationToken cancellationToken)
        {
            var blobs     = BlobHelper.GetAllFilesInContainerWithPath(string.Empty);
            var localFile = Directory.GetFiles(".", "*", SearchOption.AllDirectories);

            var toDownload = blobs.Where(blob => NotDowloaded(blob, localFile)).ToList();

            return(GetWorkItems(toDownload, workBatchFactory));
        }
Ejemplo n.º 2
0
        public IEnumerable <BatchedWorkItem> CreateWorkItems(IWorkBatchFactory workBatchFactory, CancellationToken cancellationToken)
        {
            FormattedConsole.WriteLine($"Producer {ProducerId} - Checking for work...");

            while (_workAvailableRepo.WorkAvailable())
            {
                foreach (var workItem in GetWorkItems(workBatchFactory))
                {
                    yield return(workItem);
                }
            }
        }
Ejemplo n.º 3
0
        private IEnumerable <BatchedWorkItem> GetWorkItems(IWorkBatchFactory workBatchFactory, bool startup = false)
        {
            var workBatch = workBatchFactory.Create(3, new DummyWorkBatch(), startup: startup);

            var workItems = new List <BatchedWorkItem>();

            for (var i = 0; i < 3; i++)
            {
                workItems.Add(new BatchedWorkItem(workBatch, new DummyWorkItem(_rand.Next(0, 100).ToString())));
            }

            FormattedConsole.WriteLine($"Producer {ProducerId} has created {workItems[0].Id}, {workItems[1].Id}, {workItems[2].Id}");

            return(workItems);
        }
Ejemplo n.º 4
0
        private static IEnumerable <BatchedWorkItem> GetWorkItems(IReadOnlyCollection <Uri> fileLocations, IWorkBatchFactory workBatchFactory, string batchId = null)
        {
            var batch = workBatchFactory.Create(fileLocations.Count, new BlobWatcherWorkBatch(batchId, ProcessResults));

            FormattedConsole.WriteLine($"Created batch {batch.Id} with {fileLocations.Count} blobs");

            return(fileLocations
                   .Select(uri => new BatchedWorkItem(batch, new BlobWatcherWorkItem(uri.AbsoluteUri, batch))));
        }
Ejemplo n.º 5
0
 public IEnumerable <BatchedWorkItem> CreateStartupWorkItems(IWorkBatchFactory workBatchFactory, CancellationToken cancellationToken)
 {
     // Load everything at startup
     return(GetWorkItems(BlobHelper.GetAllFilesInContainerWithPath("*"), workBatchFactory));
 }
Ejemplo n.º 6
0
 public IEnumerable <BatchedWorkItem> CreateStartupWorkItems(IWorkBatchFactory workBatchFactory, CancellationToken cancellationToken)
 {
     FormattedConsole.WriteLine($"Producer {ProducerId} - Startup");
     return(GetWorkItems(workBatchFactory, true));
 }