- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\Discovery\Memory;
|
|
|
|
/**
|
|
* Result of a guard check
|
|
*/
|
|
final readonly class GuardResult
|
|
{
|
|
public function __construct(
|
|
public MemoryStatusInfo $memoryStatus,
|
|
public array $actions,
|
|
public int $checkNumber,
|
|
public bool $emergencyMode
|
|
) {
|
|
}
|
|
|
|
public function hasAction(GuardAction $action): bool
|
|
{
|
|
return in_array($action, $this->actions, true);
|
|
}
|
|
|
|
public function hasAnyLeakDetection(): bool
|
|
{
|
|
return $this->hasAction(GuardAction::CRITICAL_LEAK_DETECTED) ||
|
|
$this->hasAction(GuardAction::HIGH_LEAK_DETECTED) ||
|
|
$this->hasAction(GuardAction::MEDIUM_LEAK_DETECTED) ||
|
|
$this->hasAction(GuardAction::LOW_LEAK_DETECTED);
|
|
}
|
|
|
|
public function requiresImmediateAction(): bool
|
|
{
|
|
return $this->hasAction(GuardAction::EMERGENCY_CLEANUP) ||
|
|
$this->hasAction(GuardAction::CRITICAL_LEAK_DETECTED);
|
|
}
|
|
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'memory_status' => $this->memoryStatus->toArray(),
|
|
'actions' => array_map(fn ($action) => $action->value, $this->actions),
|
|
'check_number' => $this->checkNumber,
|
|
'emergency_mode' => $this->emergencyMode,
|
|
];
|
|
}
|
|
}
|