Exemplo n.º 1
0
        internal FunctionExecutorBase(
            ITriggeredFunctionExecutor executor,
            IConsumer <TKey, TValue> consumer,
            int channelCapacity,
            int channelFullRetryIntervalInMs,
            ICommitStrategy <TKey, TValue> commitStrategy,
            ILogger logger)
        {
            this.executor = executor ?? throw new System.ArgumentNullException(nameof(executor));
            this.consumer = consumer ?? throw new System.ArgumentNullException(nameof(consumer));
            this.channelFullRetryIntervalInMs = channelFullRetryIntervalInMs;
            this.commitStrategy          = commitStrategy;
            this.logger                  = logger;
            this.cancellationTokenSource = new CancellationTokenSource();
            this.currentBatch            = new List <KafkaEventData>();

            this.channel = Channel.CreateBounded <KafkaEventData[]>(new BoundedChannelOptions(channelCapacity)
            {
                SingleReader = true,
                SingleWriter = true,
            });

            Task.Run(async() =>
            {
                try
                {
                    await this.ReaderAsync(this.channel.Reader, this.cancellationTokenSource.Token, this.logger);
                }
                catch (Exception ex)
                {
                    // Channel reader will throw OperationCanceledException if cancellation token is cancelled during a call
                    if (!(ex is OperationCanceledException))
                    {
                        this.logger.LogError(ex, $"Function executor error while processing channel");
                    }
                }
                finally
                {
                    this.readerFinished.Release();
                }
            });
        }
Exemplo n.º 2
0
 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)
 {
 }
Exemplo n.º 3
0
 public MultipleItemFunctionExecutor(ITriggeredFunctionExecutor executor, IConsumer <TKey, TValue> consumer, int channelCapacity, int channelFullRetryIntervalInMs, ICommitStrategy <TKey, TValue> commitStrategy, ILogger logger)
     : base(executor, consumer, channelCapacity, channelFullRetryIntervalInMs, commitStrategy, logger)
 {
     logger.LogInformation($"FunctionExecutor Loaded: {nameof(MultipleItemFunctionExecutor<TKey, TValue>)}");
 }