public async Task RegisterRoute(Uri route, ParameterInfo triggerParameter, ITriggeredFunctionExecutor executor) { await EnsureServerOpen(); string routeKey = route.LocalPath.ToLowerInvariant(); if (_functions.ContainsKey(routeKey)) { throw new InvalidOperationException(string.Format("Duplicate route detected. There is already a route registered for '{0}'", routeKey)); } _functions.AddOrUpdate(routeKey, executor, (k, v) => { return executor; }); WebHookTriggerAttribute attribute = triggerParameter.GetCustomAttribute<WebHookTriggerAttribute>(); IWebHookReceiver receiver = null; string receiverId = string.Empty; string receiverLog = string.Empty; if (attribute != null && _webHookReceiverManager.TryParseReceiver(route.LocalPath, out receiver, out receiverId)) { receiverLog = string.Format(" (Receiver: '{0}', Id: '{1}')", receiver.Name, receiverId); } MethodInfo method = (MethodInfo)triggerParameter.Member; string methodName = string.Format("{0}.{1}", method.DeclaringType, method.Name); _trace.Verbose(string.Format("WebHook route '{0}' registered for function '{1}'{2}", route.LocalPath, methodName, receiverLog)); }
public WebHookListener(WebHookDispatcher dispatcher, ParameterInfo triggerParameter, Uri route, ITriggeredFunctionExecutor executor) { _dispatcher = dispatcher; _triggerParameter = triggerParameter; _route = route; _executor = executor; }
public WebHookListener(WebHookDispatcher dispatcher, MethodInfo method, Uri route, ITriggeredFunctionExecutor executor) { _dispatcher = dispatcher; _method = method; _route = route; _executor = executor; }
public FileListener(FilesConfiguration config, FileTriggerAttribute attribute, ITriggeredFunctionExecutor triggerExecutor) { _config = config; _attribute = attribute; _triggerExecutor = triggerExecutor; _cancellationTokenSource = new CancellationTokenSource(); _watchPath = Path.Combine(_config.RootPath, _attribute.GetNormalizedPath()); }
public ServiceBusQueueListenerFactory(ServiceBusAccount account, string queueName, ITriggeredFunctionExecutor executor, AccessRights accessRights) { _namespaceManager = account.NamespaceManager; _messagingFactory = account.MessagingFactory; _queueName = queueName; _executor = executor; _accessRights = accessRights; }
public ServiceBusSubscriptionListenerFactory(ServiceBusAccount account, string topicName, string subscriptionName, ITriggeredFunctionExecutor executor, AccessRights accessRights) { _namespaceManager = account.NamespaceManager; _messagingFactory = account.MessagingFactory; _topicName = topicName; _subscriptionName = subscriptionName; _executor = executor; _accessRights = accessRights; }
public void Register(string functionId, ITriggeredFunctionExecutor executor) { if (_started) { throw new InvalidOperationException("Registrations may not be added while the shared listener is running."); } _executor.Register(functionId, executor); }
public RedisChannelListener(string channelOrKey, ITriggeredFunctionExecutor triggerExecutor, RedisConfiguration config, TraceWriter trace) : base() { _channelOrKey = channelOrKey; _triggerExecutor = triggerExecutor; _config = config; _redisProcessor = CreateProcessor(channelOrKey); _trace = trace; }
public RedisCacheListener(string channelOrKey, ITriggeredFunctionExecutor triggerExecutor, RedisConfiguration config, TraceWriter trace) : base() { _channelOrKey = channelOrKey; _triggerExecutor = triggerExecutor; _config = config; _lastValueKeyName = _config.LastValueKeyNamePrefix + channelOrKey; _redisProcessor = CreateProcessor(channelOrKey); _trace = trace; }
public TimerListener(TimerTriggerAttribute attribute, string timerName, TimersConfiguration config, ITriggeredFunctionExecutor executor) { _attribute = attribute; _timerName = timerName; _config = config; _executor = executor; _cancellationTokenSource = new CancellationTokenSource(); _schedule = _attribute.Schedule; _scheduleMonitor = _config.ScheduleMonitor; }
public QueueListenerFactory(IStorageQueue queue, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TraceWriter trace, ITriggeredFunctionExecutor executor) { if (queue == null) { throw new ArgumentNullException("queue"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (trace == null) { throw new ArgumentNullException("trace"); } if (executor == null) { throw new ArgumentNullException("executor"); } _queue = queue; _poisonQueue = CreatePoisonQueueReference(queue.ServiceClient, queue.Name); _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _trace = trace; _executor = executor; }
public async Task RegisterRoute(Uri route, string methodName, ITriggeredFunctionExecutor executor) { await EnsureServerOpen(); string routeKey = route.LocalPath.ToLowerInvariant(); if (_functions.ContainsKey(routeKey)) { throw new InvalidOperationException(string.Format("Duplicate route detected. There is already a route registered for '{0}'", routeKey)); } _functions.AddOrUpdate(routeKey, executor, (k, v) => { return executor; }); _trace.Verbose(string.Format("WebHook route '{0}' registered for function '{1}'", route.LocalPath, methodName)); }
/// <summary> /// Constructs a new instance /// </summary> /// <param name="config">The <see cref="FilesConfiguration"/></param> /// <param name="attribute">The <see cref="FileTriggerAttribute"/></param> /// <param name="executor">The function executor.</param> public FileProcessorFactoryContext(FilesConfiguration config, FileTriggerAttribute attribute, ITriggeredFunctionExecutor executor) { if (config == null) { throw new ArgumentNullException("config"); } if (attribute == null) { throw new ArgumentNullException("attribute"); } if (executor == null) { throw new ArgumentNullException("executor"); } Config = config; Attribute = attribute; Executor = executor; }
public static DurableTaskListener CreateForActivity( DurableTaskConfiguration config, string activityName, string activityVersion, ITriggeredFunctionExecutor activityFunctionExecutor) { if (activityFunctionExecutor == null) { throw new ArgumentNullException(nameof(activityFunctionExecutor)); } string key = GetFunctionKey(activityName, activityVersion); if (!activityFunctionExecutors.TryAdd(key, activityFunctionExecutor)) { // Best effort for now until we can figure out how to properly remove registrations when the listener is recycled. } return(new DurableTaskListener(config)); }
/// <summary> /// Constructs a new instance /// </summary> /// <param name="context">The <see cref="FileProcessorFactoryContext"/></param> public FileProcessor(FileProcessorFactoryContext context) { if (context == null) { throw new ArgumentNullException("context"); } _config = context.Config; _attribute = context.Attribute; _executor = context.Executor; string attributePath = _attribute.GetNormalizedPath(); _filePath = Path.Combine(_config.RootPath, attributePath); JsonSerializerSettings settings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.IsoDateFormat, }; _serializer = JsonSerializer.Create(settings); }
public SQLTriggerListener(ITriggeredFunctionExecutor executor, IChangeTracker changeTracker, SQLTriggerAttribute attribute) { if (executor == null) { throw new ArgumentNullException(nameof(executor)); } if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } if (changeTracker == null) { throw new ArgumentNullException(nameof(changeTracker)); } this._executor = executor; this._changeTracker = changeTracker; this._attribute = attribute; }
public SimpleMessageBusFileListener(IOptions <FileSystemOptions> options, SimpleMessageBusFileTriggerAttribute attribute, ITriggeredFunctionExecutor triggerExecutor, ILogger logger, ISimpleMessageBusFileProcessorFactory fileProcessorFactory) { _options = options ?? throw new ArgumentNullException(nameof(options)); _attribute = attribute ?? throw new ArgumentNullException(nameof(attribute)); _triggerExecutor = triggerExecutor ?? throw new ArgumentNullException(nameof(triggerExecutor)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _fileProcessorFactory = fileProcessorFactory ?? throw new ArgumentNullException(nameof(fileProcessorFactory)); _cancellationTokenSource = new CancellationTokenSource(); if (string.IsNullOrEmpty(_options.Value.RootFolder) || !Directory.Exists(_options.Value.RootFolder)) { throw new InvalidOperationException(string.Format("Path '{0}' is invalid. FilesConfiguration.RootPath must be set to a valid directory location.", _options.Value.RootFolder)); } //RWM: Use reflection because _attribute.GetRootPath() is internal. var dynMethod = _attribute.GetType().GetMethod("GetRootPath", BindingFlags.NonPublic | BindingFlags.Instance); var attributePath = dynMethod.Invoke(_attribute, null); _watchPath = Path.Combine(_options.Value.RootFolder, attributePath.ToString()); }
public void ExecuteAsync_IfInnerExecutorFails_ReturnsFailureResult() { // Arrange var account = new FakeAccount(); string functionId = "FunctionId"; string matchingETag = "ETag"; SetEtag(account, TestContainerName, TestBlobName, matchingETag); IBlobCausalityReader causalityReader = CreateStubCausalityReader(); FunctionResult expectedResult = new FunctionResult(false); Mock <ITriggeredFunctionExecutor> mock = new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict); mock.Setup(e => e.TryExecuteAsync( It.IsAny <TriggeredFunctionData>(), It.IsAny <CancellationToken>())) .ReturnsAsync(expectedResult) .Verifiable(); BlobQueueTriggerExecutor product = CreateProductUnderTest(causalityReader); ITriggeredFunctionExecutor innerExecutor = mock.Object; BlobQueueRegistration registration = new BlobQueueRegistration { BlobClient = account.CreateCloudBlobClient(), Executor = innerExecutor }; product.Register(functionId, registration); var message = CreateMessage(functionId, matchingETag); // Act Task <FunctionResult> task = product.ExecuteAsync(message, CancellationToken.None); // Assert Assert.False(task.Result.Succeeded); }
public QueueListenerFactory( QueueServiceClient queueServiceClient, QueueClient queue, QueuesOptions queueOptions, IWebJobsExceptionHandler exceptionHandler, SharedQueueWatcher messageEnqueuedWatcherSetter, ILoggerFactory loggerFactory, ITriggeredFunctionExecutor executor, IQueueProcessorFactory queueProcessorFactory, FunctionDescriptor descriptor) { _queue = queue ?? throw new ArgumentNullException(nameof(queue)); _queueOptions = queueOptions ?? throw new ArgumentNullException(nameof(queueOptions)); _exceptionHandler = exceptionHandler ?? throw new ArgumentNullException(nameof(exceptionHandler)); _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter ?? throw new ArgumentNullException(nameof(messageEnqueuedWatcherSetter)); _executor = executor ?? throw new ArgumentNullException(nameof(executor)); _descriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor)); _poisonQueue = CreatePoisonQueueReference(queueServiceClient, queue.Name); _loggerFactory = loggerFactory; _queueProcessorFactory = queueProcessorFactory; }
public BlobListenerFactory(IHostIdProvider hostIdProvider, BlobsOptions blobsOptions, IWebJobsExceptionHandler exceptionHandler, IContextSetter <IBlobWrittenWatcher> blobWrittenWatcherSetter, BlobTriggerQueueWriterFactory blobTriggerQueueWriterFactory, ISharedContextProvider sharedContextProvider, ILoggerFactory loggerFactory, FunctionDescriptor functionDescriptor, BlobServiceClient hostBlobServiceClient, QueueServiceClient hostQueueServiceClient, BlobServiceClient dataBlobServiceClient, QueueServiceClient dataQueueServiceClient, BlobContainerClient container, IBlobPathSource input, BlobTriggerSource triggerKind, ITriggeredFunctionExecutor executor, IHostSingletonManager singletonManager, ConcurrencyManager concurrencyManager) { _hostIdProvider = hostIdProvider ?? throw new ArgumentNullException(nameof(hostIdProvider)); _blobTriggerQueueWriterFactory = blobTriggerQueueWriterFactory ?? throw new ArgumentNullException(nameof(blobTriggerQueueWriterFactory)); _blobsOptions = blobsOptions ?? throw new ArgumentNullException(nameof(blobsOptions)); _exceptionHandler = exceptionHandler ?? throw new ArgumentNullException(nameof(exceptionHandler)); _blobWrittenWatcherSetter = blobWrittenWatcherSetter ?? throw new ArgumentNullException(nameof(blobWrittenWatcherSetter)); _sharedContextProvider = sharedContextProvider ?? throw new ArgumentNullException(nameof(sharedContextProvider)); _functionDescriptor = functionDescriptor ?? throw new ArgumentNullException(nameof(functionDescriptor)); _loggerFactory = loggerFactory; _hostBlobServiceClient = hostBlobServiceClient ?? throw new ArgumentNullException(nameof(hostBlobServiceClient)); _hostQueueServiceClient = hostQueueServiceClient ?? throw new ArgumentNullException(nameof(hostQueueServiceClient)); _dataBlobServiceClient = dataBlobServiceClient ?? throw new ArgumentNullException(nameof(dataBlobServiceClient)); _dataQueueServiceClient = dataQueueServiceClient ?? throw new ArgumentNullException(nameof(dataQueueServiceClient)); _container = container ?? throw new ArgumentNullException(nameof(container)); _input = input ?? throw new ArgumentNullException(nameof(input)); _blobTriggerSource = triggerKind; _executor = executor ?? throw new ArgumentNullException(nameof(executor)); _singletonManager = singletonManager ?? throw new ArgumentNullException(nameof(singletonManager)); _concurrencyManager = concurrencyManager ?? throw new ArgumentNullException(nameof(concurrencyManager)); }
public static IListener CreateFor(KafkaTriggerAttribute attribute, Type parameterType, ITriggeredFunctionExecutor executor, bool singleDispatch, KafkaOptions options, KafkaListenerConfiguration consumerKafkaConfiguration, ILogger logger) { var valueType = SerializationHelper.GetValueType(attribute.ValueType, attribute.AvroSchema, parameterType, out var avroSchema); var valueDeserializer = SerializationHelper.ResolveValueDeserializer(valueType, avroSchema); return((IListener)Activator.CreateInstance( typeof(KafkaListener <,>).MakeGenericType(attribute.KeyType ?? typeof(Ignore), valueType), new object[] { executor, singleDispatch, options, consumerKafkaConfiguration, valueDeserializer, logger })); }
private async Task <FunctionResult> ExecuteAsyncCore(ITriggeredFunctionExecutor executor, InvocationContext context, TaskCompletionSource <object> tcs) { var signalRTriggerEvent = new SignalRTriggerEvent { Context = context, TaskCompletionSource = tcs, }; var result = await executor.TryExecuteAsync( new TriggeredFunctionData { TriggerValue = signalRTriggerEvent }, CancellationToken.None); // If there's exception in invocation, tcs may not be set. // And SetException seems not necessary. Exception can be get from FunctionResult. if (result.Succeeded == false) { tcs?.TrySetResult(null); } return(result); }
public EventHubListener( string functionId, ITriggeredFunctionExecutor executor, EventProcessorHost eventProcessorHost, bool singleDispatch, EventHubOptions options, ILogger logger, BlobContainerClient blobContainer = null) { _executor = executor; _eventProcessorHost = eventProcessorHost; _singleDispatch = singleDispatch; _options = options; _logger = logger; _scaleMonitor = new Lazy <EventHubsScaleMonitor>(() => new EventHubsScaleMonitor( functionId, eventProcessorHost.EventHubName, eventProcessorHost.ConsumerGroupName, eventProcessorHost.EventHubConnectionString, eventProcessorHost.StorageConnectionString, _logger, blobContainer)); }
public async Task ExecuteAsync_IfBlobIsUnchanged_CallsInnerExecutor() { // Arrange string functionId = "FunctionId"; string matchingETag = "ETag"; Guid expectedParentId = Guid.NewGuid(); IStorageQueueMessage message = CreateMessage(functionId, matchingETag); IBlobETagReader eTagReader = CreateStubETagReader(matchingETag); IBlobCausalityReader causalityReader = CreateStubCausalityReader(expectedParentId); FunctionResult expectedResult = new FunctionResult(true); Mock <ITriggeredFunctionExecutor> mock = new Mock <ITriggeredFunctionExecutor>(MockBehavior.Strict); mock.Setup(e => e.TryExecuteAsync(It.IsAny <TriggeredFunctionData>(), It.IsAny <CancellationToken>())) .Callback <TriggeredFunctionData, CancellationToken>( (mockInput, mockCancellationToken) => { Assert.Equal(expectedParentId, mockInput.ParentId); StorageBlockBlob resultBlob = (StorageBlockBlob)mockInput.TriggerValue; Assert.Equal(TestBlobName, resultBlob.Name); }) .ReturnsAsync(expectedResult) .Verifiable(); ITriggeredFunctionExecutor innerExecutor = mock.Object; BlobQueueTriggerExecutor product = CreateProductUnderTest(eTagReader, causalityReader); product.Register(functionId, innerExecutor); // Act FunctionResult result = await product.ExecuteAsync(message, CancellationToken.None); // Assert Assert.Same(expectedResult, result); mock.Verify(); }
/// <summary> /// Constructs a new instance /// </summary> /// <param name="config">The <see cref="FilesConfiguration"/></param> /// <param name="attribute">The <see cref="FileTriggerAttribute"/></param> /// <param name="executor">The function executor.</param> /// <param name="trace">The <see cref="TraceWriter"/>.</param> public FileProcessorFactoryContext(FilesConfiguration config, FileTriggerAttribute attribute, ITriggeredFunctionExecutor executor, TraceWriter trace) { if (config == null) { throw new ArgumentNullException("config"); } if (attribute == null) { throw new ArgumentNullException("attribute"); } if (executor == null) { throw new ArgumentNullException("executor"); } if (trace == null) { throw new ArgumentNullException("trace"); } Config = config; Attribute = attribute; Executor = executor; Trace = trace; }
public EventHubListener( string functionId, ITriggeredFunctionExecutor executor, EventProcessorHost eventProcessorHost, bool singleDispatch, IEventHubConsumerClient consumerClient, BlobsCheckpointStore checkpointStore, EventHubOptions options, ILogger logger) { _logger = logger; _executor = executor; _eventProcessorHost = eventProcessorHost; _singleDispatch = singleDispatch; _checkpointStore = checkpointStore; _options = options; _scaleMonitor = new Lazy <EventHubsScaleMonitor>( () => new EventHubsScaleMonitor( functionId, consumerClient, checkpointStore, _logger)); }
public static async Task <WrappedFunctionResult> ExecuteActivityFunction( ITriggeredFunctionExecutor executor, TriggeredFunctionData triggerInput, CancellationToken cancellationToken) { #pragma warning disable CS0618 // InvokeHandler approved for use by this extension if (triggerInput.InvokeHandler != null) { // Activity functions cannot use InvokeHandler, because the usage of InvokeHandler prevents the function from // returning a value in the way that the Activity shim knows how to handle. throw new ArgumentException( $"{nameof(ExecuteActivityFunction)} cannot be used when ${nameof(triggerInput)} has a value for ${nameof(TriggeredFunctionData.InvokeHandler)}"); } #pragma warning restore CS0618 try { FunctionResult result = await executor.TryExecuteAsync(triggerInput, cancellationToken); if (result.Succeeded) { return(WrappedFunctionResult.Success()); } if (cancellationToken.IsCancellationRequested) { return(WrappedFunctionResult.FunctionRuntimeFailure(result.Exception)); } return(WrappedFunctionResult.UserCodeFailure(result.Exception)); } catch (Exception e) { return(WrappedFunctionResult.FunctionRuntimeFailure(e)); } }
public KafkaListener( ITriggeredFunctionExecutor executor, bool singleDispatch, KafkaOptions options, KafkaListenerConfiguration kafkaListenerConfiguration, bool requiresKey, IDeserializer <TValue> valueDeserializer, ILogger logger, string functionId) { this.ValueDeserializer = valueDeserializer; this.executor = executor; this.singleDispatch = singleDispatch; this.options = options; this.listenerConfiguration = kafkaListenerConfiguration; this.requiresKey = requiresKey; this.logger = logger; this.cancellationTokenSource = new CancellationTokenSource(); this.consumerGroup = string.IsNullOrEmpty(this.listenerConfiguration.ConsumerGroup) ? "$Default" : this.listenerConfiguration.ConsumerGroup; this.topicName = this.listenerConfiguration.Topic; this.functionId = functionId; this.consumer = new Lazy <IConsumer <TKey, TValue> >(() => CreateConsumer()); this.topicScaler = new Lazy <KafkaTopicScaler <TKey, TValue> >(() => CreateTopicScaler()); }
public QueueTriggerExecutor(ITriggeredFunctionExecutor innerExecutor) { _innerExecutor = innerExecutor; }
internal RegisteredFunctionInfo(ITriggeredFunctionExecutor executor, bool isOutOfProc) { this.Executor = executor; this.IsOutOfProc = isOutOfProc; }
public RedisSubListener(ITriggeredFunctionExecutor executor, RedisSubTriggerAttribute attribute) { _executor = executor; _attribute = attribute; _connection = ConnectionMultiplexer.Connect(attribute.GetConnectionString()); }
public BlobListenerFactory(IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TraceWriter trace, string functionId, IStorageAccount hostAccount, IStorageAccount dataAccount, IStorageBlobContainer container, IBlobPathSource input, ITriggeredFunctionExecutor executor, SingletonManager singletonManager) { if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (trace == null) { throw new ArgumentNullException("trace"); } if (hostAccount == null) { throw new ArgumentNullException("hostAccount"); } if (dataAccount == null) { throw new ArgumentNullException("dataAccount"); } if (container == null) { throw new ArgumentNullException("container"); } if (input == null) { throw new ArgumentNullException("input"); } if (executor == null) { throw new ArgumentNullException("executor"); } if (singletonManager == null) { throw new ArgumentNullException("singletonManager"); } _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _trace = trace; _functionId = functionId; _hostAccount = hostAccount; _dataAccount = dataAccount; _container = container; _input = input; _executor = executor; _singletonManager = singletonManager; }
public ServiceBusTriggerExecutor(ITriggeredFunctionExecutor<BrokeredMessage> innerExecutor) { _innerExecutor = innerExecutor; }
public FakeQueueListener(ITriggeredFunctionExecutor executor, FakeQueueClient client, bool singleDispatch) { this._executor = executor; this._singleDispatch = singleDispatch; this._client = client; }
/// <summary> /// Creates a new instance /// </summary> /// <param name="descriptor">The <see cref="FunctionDescriptor"/> to create a listener for.</param> /// <param name="executor">The <see cref="ITriggeredFunctionExecutor"/> that should be used to invoke the /// target job function when the trigger fires.</param> /// <param name="sharedQueue">The shared queue.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param> internal ListenerFactoryContext(FunctionDescriptor descriptor, ITriggeredFunctionExecutor executor, SharedQueueHandler sharedQueue, CancellationToken cancellationToken) : this(descriptor, executor, cancellationToken) { _sharedQueue = sharedQueue; }
public BlobListenerFactory(IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TextWriter log, string functionId, IStorageAccount account, IStorageBlobContainer container, IBlobPathSource input, ITriggeredFunctionExecutor<IStorageBlob> executor) { if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (log == null) { throw new ArgumentNullException("log"); } if (account == null) { throw new ArgumentNullException("account"); } if (container == null) { throw new ArgumentNullException("container"); } if (input == null) { throw new ArgumentNullException("input"); } if (executor == null) { throw new ArgumentNullException("executor"); } _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _log = log; _functionId = functionId; _account = account; _container = container; _input = input; _executor = executor; }
public NewEntityTriggerListener(ITriggeredFunctionExecutor executor) { _executor = executor; }
public RabbitMqTriggerAttributeListener(IModel channel, string queueName, ITriggeredFunctionExecutor contextExecutor) { _channel = channel; _queueName = queueName; _contextExecutor = contextExecutor; }
public ServiceBusTriggerExecutor(ITriggeredFunctionExecutor innerExecutor) { _innerExecutor = innerExecutor; }
public IListenerFactory CreateListenerFactory(FunctionDescriptor descriptor, ITriggeredFunctionExecutor executor) { return new QueueListenerFactory(_queue, _queueConfiguration, _backgroundExceptionDispatcher, _messageEnqueuedWatcherSetter, _sharedContextProvider, _log, executor); }
/// <summary> /// Creates a new instance /// </summary> /// <param name="descriptor">The <see cref="FunctionDescriptor"/> to create a listener for.</param> /// <param name="executor">The <see cref="ITriggeredFunctionExecutor"/> that should be used to invoke the /// target job function when the trigger fires.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param> public ListenerFactoryContext(FunctionDescriptor descriptor, ITriggeredFunctionExecutor executor, CancellationToken cancellationToken) { Descriptor = descriptor; Executor = executor; CancellationToken = cancellationToken; }
public RedisCacheListener(RedisConfiguration configuration, IRedisAttribute attribute, ITriggeredFunctionExecutor triggerExecutor) { _configuration = configuration; _attribute = attribute; _triggerExecutor = triggerExecutor; _redisProcessor = CreateProcessor(_attribute.ChannelOrKey); _lastValueKeyName = _configuration.LastValueKeyNamePrefix + _attribute.ChannelOrKey; }
public MongoDbListener(Type genericType, string collectionName, string connectionString, ITriggeredFunctionExecutor contextExecutor) { _genericType = genericType; _contextExecutor = contextExecutor; _collectionName = collectionName; _connectionString = connectionString; }
public ListenerFactory(FunctionDescriptor descriptor, ITriggeredFunctionExecutor executor, ITriggerBinding binding) { _descriptor = descriptor; _executor = executor; _binding = binding; }
public SingleItemFunctionExecutor(ITriggeredFunctionExecutor executor, IConsumer <TKey, TValue> consumer, int channelCapacity, int channelFullRetryIntervalInMs, ICommitStrategy <TKey, TValue> commitStrategy, ILogger logger) : base(executor, consumer, channelCapacity, channelFullRetryIntervalInMs, commitStrategy, logger) { }
public TimerListener(TimerTriggerAttribute attribute, string timerName, TimersConfiguration config, ITriggeredFunctionExecutor executor, TraceWriter trace) { _attribute = attribute; _timerName = timerName; _config = config; _executor = executor; _trace = trace; _cancellationTokenSource = new CancellationTokenSource(); _schedule = _attribute.Schedule; ScheduleMonitor = _attribute.UseMonitor ? _config.ScheduleMonitor : null; }
public IListenerFactory CreateListenerFactory(FunctionDescriptor descriptor, ITriggeredFunctionExecutor executor) { if (_queueName != null) { return new ServiceBusQueueListenerFactory(_account, _queueName, executor, _accessRights); } else { return new ServiceBusSubscriptionListenerFactory(_account, _topicName, _subscriptionName, executor, _accessRights); } }
public ServiceBusListener( string functionId, ServiceBusEntityType entityType, string entityPath, bool isSessionsEnabled, bool autoCompleteMessages, ITriggeredFunctionExecutor triggerExecutor, ServiceBusOptions options, string connection, MessagingProvider messagingProvider, ILoggerFactory loggerFactory, bool singleDispatch, ServiceBusClientFactory clientFactory, ConcurrencyManager concurrencyManager) { _entityPath = entityPath; _isSessionsEnabled = isSessionsEnabled; _autoCompleteMessages = autoCompleteMessages; _triggerExecutor = triggerExecutor; _cancellationTokenSource = new CancellationTokenSource(); _logger = loggerFactory.CreateLogger <ServiceBusListener>(); _functionId = functionId; _client = new Lazy <ServiceBusClient>( () => clientFactory.CreateClientFromSetting(connection)); _batchReceiver = new Lazy <ServiceBusReceiver>( () => messagingProvider.CreateBatchMessageReceiver( _client.Value, _entityPath, options.ToReceiverOptions())); _messageProcessor = new Lazy <MessageProcessor>( () => { var processorOptions = options.ToProcessorOptions(_autoCompleteMessages, concurrencyManager.Enabled); return(messagingProvider.CreateMessageProcessor(_client.Value, _entityPath, processorOptions)); }); _sessionMessageProcessor = new Lazy <SessionMessageProcessor>( () => { var sessionProcessorOptions = options.ToSessionProcessorOptions(_autoCompleteMessages, concurrencyManager.Enabled); return(messagingProvider.CreateSessionMessageProcessor(_client.Value, _entityPath, sessionProcessorOptions)); }); _scaleMonitor = new Lazy <ServiceBusScaleMonitor>( () => new ServiceBusScaleMonitor( functionId, entityType, _entityPath, connection, _batchReceiver, loggerFactory, clientFactory)); if (concurrencyManager.Enabled) { _concurrencyUpdateManager = new ConcurrencyUpdateManager(concurrencyManager, _messageProcessor, _sessionMessageProcessor, _isSessionsEnabled, _functionId, _logger); } _singleDispatch = singleDispatch; _serviceBusOptions = options; _details = new Lazy <string>(() => $"namespace='{_client.Value?.FullyQualifiedNamespace}', enityPath='{_entityPath}', singleDispatch='{_singleDispatch}', " + $"isSessionsEnabled='{_isSessionsEnabled}', functionId='{_functionId}'"); }
public ErrorTriggerListener(JobHostConfiguration config, ParameterInfo parameter, ITriggeredFunctionExecutor executor) { _config = config; _traceMonitor = CreateTraceMonitor(parameter, executor); }
internal OrchestratorInfo(ITriggeredFunctionExecutor executor, bool isOutOfProc) { this.Executor = executor; this.IsOutOfProc = isOutOfProc; }
internal static TraceMonitor CreateTraceMonitor(ParameterInfo parameter, ITriggeredFunctionExecutor executor) { ErrorTriggerAttribute attribute = parameter.GetCustomAttribute<ErrorTriggerAttribute>(inherit: false); // Determine whether this is a method level filter, and if so, create the filter Func<TraceEvent, bool> methodFilter = null; MethodInfo method = (MethodInfo)parameter.Member; string functionLevelMessage = null; if (method.Name.EndsWith(ErrorHandlerSuffix, StringComparison.OrdinalIgnoreCase)) { string sourceMethodName = method.Name.Substring(0, method.Name.Length - ErrorHandlerSuffix.Length); MethodInfo sourceMethod = method.DeclaringType.GetMethod(sourceMethodName); if (sourceMethod != null) { string sourceMethodFullName = string.Format("{0}.{1}", method.DeclaringType.FullName, sourceMethod.Name); methodFilter = p => { FunctionInvocationException functionException = p.Exception as FunctionInvocationException; return p.Level == System.Diagnostics.TraceLevel.Error && functionException != null && string.Compare(functionException.MethodName, sourceMethodFullName, StringComparison.OrdinalIgnoreCase) == 0; }; string sourceMethodShortName = string.Format("{0}.{1}", method.DeclaringType.Name, sourceMethod.Name); functionLevelMessage = string.Format("Function '{0}' failed.", sourceMethodShortName); } } string errorHandlerFullName = string.Format("{0}.{1}", method.DeclaringType.FullName, method.Name); ErrorHandlers.Add(errorHandlerFullName); // Create the TraceFilter instance TraceFilter traceFilter = null; if (attribute.FilterType != null) { if (methodFilter != null) { TraceFilter innerTraceFilter = (TraceFilter)Activator.CreateInstance(attribute.FilterType); traceFilter = new CompositeTraceFilter(innerTraceFilter, methodFilter, attribute.Message ?? functionLevelMessage); } else { traceFilter = (TraceFilter)Activator.CreateInstance(attribute.FilterType); } } else if (!string.IsNullOrEmpty(attribute.Window)) { TimeSpan window = TimeSpan.Parse(attribute.Window); traceFilter = new SlidingWindowTraceFilter(window, attribute.Threshold, methodFilter, attribute.Message); } else { traceFilter = TraceFilter.Create(methodFilter, attribute.Message ?? functionLevelMessage); } TraceMonitor traceMonitor = new TraceMonitor().Filter(traceFilter); // Apply any additional monitor options if (!string.IsNullOrEmpty(attribute.Throttle)) { TimeSpan throttle = TimeSpan.Parse(attribute.Throttle); traceMonitor.Throttle(throttle); } // Subscribe the error handler function to the error stream traceMonitor.Subscribe(p => { TriggeredFunctionData triggerData = new TriggeredFunctionData { TriggerValue = p }; Task<FunctionResult> task = executor.TryExecuteAsync(triggerData, CancellationToken.None); task.Wait(); }); return traceMonitor; }
/// <summary> /// Constructs a new instance /// </summary> /// <param name="options">The <see cref="FilesOptions"/></param> /// <param name="attribute">The <see cref="FileTriggerAttribute"/></param> /// <param name="executor">The function executor.</param> /// <param name="logger">The <see cref="ILogger"/>.</param> public FileProcessorFactoryContext(FilesOptions options, FileTriggerAttribute attribute, ITriggeredFunctionExecutor executor, ILogger logger) { Options = options ?? throw new ArgumentNullException(nameof(options)); Attribute = attribute ?? throw new ArgumentNullException(nameof(attribute)); Executor = executor ?? throw new ArgumentNullException(nameof(executor)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public Listener(ITriggeredFunctionExecutor executor) { _executor = executor; // TODO: For this sample, we're using a timer to generate // trigger events. You'll replace this with your event source. _timer = new System.Timers.Timer(5 * 1000) { AutoReset = true }; _timer.Elapsed += OnTimer; }
public AdlsFileWatcherListener(ITriggeredFunctionExecutor executor, AdlsWatcherTriggerAttribute adlsWatcherTriggerAttribute) { Executor = executor; this.adlsWatcherTriggerAttribute = adlsWatcherTriggerAttribute; }
public IListenerFactory CreateListenerFactory(FunctionDescriptor descriptor, ITriggeredFunctionExecutor executor) { if (descriptor == null) { throw new ArgumentNullException("descriptor"); } IStorageBlobContainer container = _client.GetContainerReference(_path.ContainerNamePattern); IListenerFactory listenerFactory = new BlobListenerFactory(_hostIdProvider, _queueConfiguration, _backgroundExceptionDispatcher, _blobWrittenWatcherSetter, _messageEnqueuedWatcherSetter, _sharedContextProvider, _log, descriptor.Id, _account, container, _path, executor); return listenerFactory; }