public async Task CloseAsync()

in src/Microsoft.Azure.WebJobs.Extensions.Kafka/Trigger/FunctionExecutorBase.cs [152:181]


        public async Task<bool> CloseAsync()
        {
            if (this.isClosed)
            {
                return true;
            }

            try
            {

                if (!drainModeManager.IsDrainModeEnabled)
                {
                    functionExecutionCancellationTokenSource.Cancel();
                }

                this.channel.Writer.Complete();

                if (await this.readerFinished.WaitAsync(TimeSpan.FromSeconds(300)))
                {
                    this.isClosed = true;
                    return true;
                }
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex, "Failed to close Kafka trigger executor");
            }

            return false;
        }