- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
93 lines
2.5 KiB
PHP
93 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\Queue\ValueObjects;
|
|
|
|
/**
|
|
* Job status enumeration for tracking job lifecycle
|
|
*/
|
|
enum JobStatus: string
|
|
{
|
|
case PENDING = 'pending'; // Job created, waiting in queue
|
|
case PROCESSING = 'processing'; // Job being processed
|
|
case COMPLETED = 'completed'; // Job completed successfully
|
|
case FAILED = 'failed'; // Job failed with error
|
|
case RETRYING = 'retrying'; // Job failed, retrying
|
|
case CANCELLED = 'cancelled'; // Job was cancelled
|
|
case EXPIRED = 'expired'; // Job expired (timeout)
|
|
|
|
/**
|
|
* Get human-readable label
|
|
*/
|
|
public function getLabel(): string
|
|
{
|
|
return match ($this) {
|
|
self::PENDING => 'Pending',
|
|
self::PROCESSING => 'Processing',
|
|
self::COMPLETED => 'Completed',
|
|
self::FAILED => 'Failed',
|
|
self::RETRYING => 'Retrying',
|
|
self::CANCELLED => 'Cancelled',
|
|
self::EXPIRED => 'Expired',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Check if status represents a final state
|
|
*/
|
|
public function isFinal(): bool
|
|
{
|
|
return match ($this) {
|
|
self::COMPLETED, self::CANCELLED, self::EXPIRED => true,
|
|
default => false
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Check if status represents an active state
|
|
*/
|
|
public function isActive(): bool
|
|
{
|
|
return match ($this) {
|
|
self::PENDING, self::PROCESSING, self::RETRYING => true,
|
|
default => false
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Check if status represents a failure state
|
|
*/
|
|
public function isFailure(): bool
|
|
{
|
|
return match ($this) {
|
|
self::FAILED, self::EXPIRED => true,
|
|
default => false
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get next possible statuses from current status
|
|
*
|
|
* @return self[]
|
|
*/
|
|
public function getNextPossibleStatuses(): array
|
|
{
|
|
return match ($this) {
|
|
self::PENDING => [self::PROCESSING, self::CANCELLED],
|
|
self::PROCESSING => [self::COMPLETED, self::FAILED, self::CANCELLED, self::EXPIRED],
|
|
self::RETRYING => [self::PROCESSING, self::FAILED, self::CANCELLED],
|
|
self::FAILED => [self::RETRYING, self::CANCELLED],
|
|
default => [] // Final states have no transitions
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Check if transition to another status is valid
|
|
*/
|
|
public function canTransitionTo(self $newStatus): bool
|
|
{
|
|
return in_array($newStatus, $this->getNextPossibleStatuses(), true);
|
|
}
|
|
}
|