Mini Heartbeat

The Mini Heartbeat is an additional function to increase the performance and speed of pipeline processing.

Besides the normal heartbeat, which can get executed every minute, the Mini-Heartbeat gets executed directly at the end of a step processing with the PipelineRunner (Consumer).

The following steps get executed within the pipeline instead of waiting for the next heartbeat.

Accordingly, steps that only run for seconds or milliseconds can be executed quickly, one after the other, without waiting for the next heartbeat.

functionality can get activated with a mini heartbeat configuration::
Mini Heartbeat execution function \TechDivision\ProcessPipelines\Model\MiniHeartbeat::process
<?php

public function process(int $pipelineId)
{
    if (!$this->isMiniHeartbeatAllowed->execute()) {
        $this->heartbeatLogger->info('Mini heartbeat is not allowed.');
        return;
    }

    if ($this->lockManager->isLocked(PipelineHeartbeat::HEARTBEAT_LOCK_KEY)) {
        ...
        return;
    }

    $lockName = $this->getLockName($pipelineId);
    if ($this->lockManager->isLocked($lockName)) {
        ...
        return;
    }

    $this->lockManager->lock($lockName);
    try {
        $pipeline = $this->getPipelineById->execute($pipelineId);
        if ($this->isMaintenanceModeEnabled->execute()) {
            $this->heartbeatLogger->info('Maintenance mode is active for mini heartbeat.');
        } else {
            $this->executeAllPendingStepsByPipelineCommand->execute($pipeline);
            $this->cancelPipelineIfExpiredCommand->execute($pipeline);
        }
        $this->updatePipelineStatusCommand->execute($pipeline);
        $this->lockManager->unlock($lockName);
    } catch (Throwable $throwable) {
        $this->lockManager->unlock($lockName);
        throw $throwable;
    }
}