2022-12-30 21:54:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2020-09-24 11:45:20 +02:00
|
|
|
|
|
|
|
namespace danog\MadelineProto\Ipc;
|
|
|
|
|
2022-12-30 19:21:36 +01:00
|
|
|
use Throwable;
|
|
|
|
|
2020-09-24 11:45:20 +02:00
|
|
|
/**
|
|
|
|
* IPC state class.
|
2023-02-16 18:38:47 +01:00
|
|
|
*
|
|
|
|
* @internal
|
2020-09-24 11:45:20 +02:00
|
|
|
*/
|
|
|
|
final class IpcState
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Startup time.
|
|
|
|
*/
|
|
|
|
private float $startupTime;
|
|
|
|
/**
|
|
|
|
* Startup ID.
|
|
|
|
*/
|
|
|
|
private int $startupId;
|
|
|
|
/**
|
|
|
|
* Exception.
|
|
|
|
*/
|
2020-09-27 19:36:17 +02:00
|
|
|
private ?ExitFailure $exception;
|
2020-09-24 11:45:20 +02:00
|
|
|
/**
|
|
|
|
* Construct.
|
|
|
|
*/
|
2023-01-04 15:13:55 +01:00
|
|
|
public function __construct(int $startupId, ?Throwable $exception = null)
|
2020-09-24 11:45:20 +02:00
|
|
|
{
|
|
|
|
$this->startupTime = \microtime(true);
|
|
|
|
$this->startupId = $startupId;
|
2020-09-27 19:36:17 +02:00
|
|
|
$this->exception = $exception ? new ExitFailure($exception) : null;
|
2020-09-24 11:45:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get startup time.
|
|
|
|
*/
|
|
|
|
public function getStartupTime(): float
|
|
|
|
{
|
|
|
|
return $this->startupTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get startup ID.
|
|
|
|
*/
|
|
|
|
public function getStartupId(): int
|
|
|
|
{
|
|
|
|
return $this->startupId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get exception.
|
|
|
|
*/
|
2022-12-30 19:21:36 +01:00
|
|
|
public function getException(): ?Throwable
|
2020-09-24 11:45:20 +02:00
|
|
|
{
|
2020-09-27 19:36:17 +02:00
|
|
|
return $this->exception ? $this->exception->getException() : null;
|
2020-09-24 11:45:20 +02:00
|
|
|
}
|
|
|
|
}
|