public async Task <IListener> CreateAsync(IFunctionExecutor executor, CancellationToken cancellationToken) { SharedQueueWatcher sharedQueueWatcher = _sharedContextProvider.GetOrCreate <SharedQueueWatcher>( new SharedQueueWatcherFactory(_messageEnqueuedWatcherSetter)); SharedBlobListener sharedBlobListener = _sharedContextProvider.GetOrCreate <SharedBlobListener>( new SharedBlobListenerFactory(_account, _backgroundExceptionDispatcher, _blobWrittenWatcherSetter)); // Note that these clients are intentionally for the storage account rather than for the dashboard account. // We use the storage, not dashboard, account for the blob receipt container and blob trigger queues. IStorageQueueClient queueClient = _account.CreateQueueClient(); IStorageBlobClient blobClient = _account.CreateBlobClient(); string hostId = await _hostIdProvider.GetHostIdAsync(cancellationToken); string hostBlobTriggerQueueName = HostQueueNames.GetHostBlobTriggerQueueName(hostId); IStorageQueue hostBlobTriggerQueue = queueClient.GetQueueReference(hostBlobTriggerQueueName); IListener blobDiscoveryToQueueMessageListener = await CreateBlobDiscoveryToQueueMessageListenerAsync( hostId, sharedBlobListener, blobClient, hostBlobTriggerQueue, sharedQueueWatcher, cancellationToken); IListener queueMessageToTriggerExecutionListener = CreateQueueMessageToTriggerExecutionListener(executor, _sharedContextProvider, sharedQueueWatcher, queueClient, hostBlobTriggerQueue, blobClient, sharedBlobListener.BlobWritterWatcher); IListener compositeListener = new CompositeListener( blobDiscoveryToQueueMessageListener, queueMessageToTriggerExecutionListener); return(compositeListener); }
public void Run() { StreamSink <int> sX = new StreamSink <int>(); StreamSink <int> sY = new StreamSink <int>(); // Should throw an exception because you're not allowed to use Send() inside // a callback. IListener l = new CompositeListener(new[] { sX.Listen(x => sY.Send(x)), sY.Listen(Console.WriteLine) }); sX.Send(1); sX.Send(2); sX.Send(3); l.Unlisten(); }