protected override HealthStatus GetBatchStatus()

in src/Epam.Kafka.PubSub/Publication/HealthChecks/PublicationHealthCheck.cs [42:73]


    protected override HealthStatus GetBatchStatus()
    {
        TimeSpan handlerTimespan = this.UtcNow - this._monitor.Batch.TimestampUtc;

        if (this._monitor.Batch.Value is BatchStatus.None or BatchStatus.Finished)
        {
            if (handlerTimespan > this.Options.HealthChecksThresholdBatch)
            {
                return HealthStatus.Unhealthy;
            }
        }

        if (this._monitor.Batch.Value is BatchStatus.Running or BatchStatus.Reading or BatchStatus.Commiting)
        {
            if (handlerTimespan > this.Options.HandlerTimeout)
            {
                return HealthStatus.Unhealthy;
            }
        }

        if (this._monitor.Batch.Value == BatchStatus.Queued)
        {
            if (this.QueuedHealthStatus(handlerTimespan, out HealthStatus healthStatus)) return healthStatus;
        }

        if (this._monitor.Result.Value is PublicationBatchResult.Error or PublicationBatchResult.ProcessedPartial)
        {
            return HealthStatus.Degraded;
        }

        return HealthStatus.Healthy;
    }