public SharedBlobListener(IStorageAccount storageAccount, IBackgroundExceptionDispatcher backgroundExceptionDispatcher) { _strategy = CreateStrategy(storageAccount); // Start the first iteration immediately. _timer = new TaskSeriesTimer(_strategy, backgroundExceptionDispatcher, initialWait: Task.Delay(0)); }
public SharedBlobListener(string hostId, StorageAccount storageAccount, IWebJobsExceptionHandler exceptionHandler) { _strategy = CreateStrategy(hostId, storageAccount); // Start the first iteration immediately. _timer = new TaskSeriesTimer(_strategy, exceptionHandler, initialWait: Task.Delay(0)); }
public static TaskSeriesCommandResult Execute(this IBlobListenerStrategy strategy) { if (strategy == null) { throw new ArgumentNullException("strategy"); } return(strategy.ExecuteAsync(CancellationToken.None).GetAwaiter().GetResult()); }
public static void Register(this IBlobListenerStrategy strategy, BlobServiceClient blobServiceClient, BlobContainerClient container, ITriggerExecutor <BlobTriggerExecutorContext> triggerExecutor) { if (strategy == null) { throw new ArgumentNullException("strategy"); } strategy.RegisterAsync(blobServiceClient, container, triggerExecutor, CancellationToken.None).GetAwaiter().GetResult(); }
public static void Start(this IBlobListenerStrategy strategy, CloudBlobContainer container, ITriggerExecutor <ICloudBlob> triggerExecutor) { if (strategy == null) { throw new ArgumentNullException("strategy"); } strategy.Start(); }
public static void Register(this IBlobListenerStrategy strategy, CloudBlobContainer container, ITriggerExecutor <ICloudBlob> triggerExecutor) { if (strategy == null) { throw new ArgumentNullException("strategy"); } strategy.RegisterAsync(container, triggerExecutor, CancellationToken.None).GetAwaiter().GetResult(); }
private void RunExecuteWithMultiPollingInterval(List <string> expectedBlobNames , IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor, int expectedCount) { // make sure it is processed in chunks of "expectedCount" size for (int i = 0; i < expectedBlobNames.Count; i += expectedCount) { RunExecuterWithExpectedBlobsInternal(expectedBlobNames, product, executor, Math.Min(expectedCount, expectedBlobNames.Count - i)); } }
private void AssertLogPollStrategyUsed(IBlobListenerStrategy product, int containerCount) { PollLogsStrategy containersRegisteredForLogPolling = (PollLogsStrategy)typeof(ScanBlobScanLogHybridPollingStrategy) .GetField("_pollLogStrategy", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(product); IDictionary <CloudBlobContainer, ICollection <ITriggerExecutor <ICloudBlob> > > logPollingContainers = (IDictionary <CloudBlobContainer, ICollection <ITriggerExecutor <ICloudBlob> > >) typeof(PollLogsStrategy) .GetField("_registrations", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(containersRegisteredForLogPolling); Assert.Equal(logPollingContainers.ToList().Count, containerCount); }
public SharedBlobListener(string hostId, BlobServiceClient blobServiceClient, IWebJobsExceptionHandler exceptionHandler, ILogger <BlobListener> logger) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (exceptionHandler == null) { throw new ArgumentNullException(nameof(exceptionHandler)); } _strategy = CreateStrategy(hostId, blobServiceClient, exceptionHandler, logger); // Start the first iteration immediately. _timer = new TaskSeriesTimer(_strategy, exceptionHandler, initialWait: Task.Delay(0)); }
private void RunExecuterWithExpectedBlobsInternal(List <string> expectedBlobNames , IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor, int expectedCount) { if (expectedBlobNames.Count == 0) { executor.ExecuteLambda = (_) => { throw new InvalidOperationException("shouldn't be any blobs in the container"); }; product.Execute().Wait.Wait(); } else { int count = 0; executor.ExecuteLambda = (b) => { count++; Assert.True(expectedBlobNames.Any(blob => blob == b.Name)); return(true); }; product.Execute(); Assert.Equal(expectedCount, count); } }
private void RunExecuteWithMultiPollingInterval(List <string> expectedBlobNames, IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor, int expectedCount) { // a map so we can track retries in the event of failures Dictionary <string, int> blobNameMap = expectedBlobNames.ToDictionary(n => n, n => 0); // make sure it is processed in chunks of "expectedCount" size for (int i = 0; i < expectedBlobNames.Count; i += expectedCount) { RunExecuterWithExpectedBlobsInternal(blobNameMap, product, executor, Math.Min(expectedCount, expectedBlobNames.Count - i)); } }
private void RunExecuterWithExpectedBlobs(IDictionary <string, int> blobNameMap, IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor) { RunExecuterWithExpectedBlobsInternal(blobNameMap, product, executor, blobNameMap.Count); }
private void RunExecuterWithExpectedBlobs(List <string> blobNames, IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor) { var blobNameMap = blobNames.ToDictionary(n => n, n => 0); RunExecuterWithExpectedBlobsInternal(blobNameMap, product, executor, blobNames.Count); }
private void RunExecuterWithExpectedBlobsInternal(IDictionary <string, int> blobNameMap, IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor, int expectedCount) { if (blobNameMap.Count == 0) { executor.ExecuteLambda = (_) => { throw new InvalidOperationException("shouldn't be any blobs in the container"); }; product.Execute().Wait.Wait(); } else { int count = 0; executor.ExecuteLambda = (b) => { Assert.Contains(blobNameMap.Keys, blob => blob == b.Name); blobNameMap[b.Name]++; if (b.DownloadText() == "throw") { // only increment if it's the first time. // other calls are re-tries. if (blobNameMap[b.Name] == 1) { count++; } return(false); } count++; return(true); }; product.Execute(); Assert.Equal(expectedCount, count); } }
private void RunExecuterWithExpectedBlobs(List <string> expectedBlobNames, IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor) { RunExecuterWithExpectedBlobsInternal(expectedBlobNames, product, executor, expectedBlobNames.Count); }