-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move process and status information into separate classes, #4
* Provide only getters to objects in response decorator * Add parsing of process information, if available
- Loading branch information
1 parent
cd59b0a
commit 3730749
Showing
6 changed files
with
593 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace hollodotme\FastCGI\Responses\PhpFpm; | ||
|
||
use DateTimeImmutable; | ||
|
||
final class Process | ||
{ | ||
/** @var array */ | ||
private $processData; | ||
|
||
public function __construct( array $processData ) | ||
{ | ||
$this->processData = $processData; | ||
} | ||
|
||
public function getPid() : int | ||
{ | ||
return $this->processData['pid'] ?? 0; | ||
} | ||
|
||
public function getState() : string | ||
{ | ||
return $this->processData['state'] ?? '-'; | ||
} | ||
|
||
public function getStartTime() : DateTimeImmutable | ||
{ | ||
return $this->processData['start time'] ?? new DateTimeImmutable( '01/Jan/1970:00:00:00 +0000' ); | ||
} | ||
|
||
public function getStartSince() : int | ||
{ | ||
return $this->processData['start since'] ?? 0; | ||
} | ||
|
||
public function getRequests() : int | ||
{ | ||
return $this->processData['requests'] ?? 0; | ||
} | ||
|
||
public function getRequestDuration() : int | ||
{ | ||
return $this->processData['request duration'] ?? 0; | ||
} | ||
|
||
public function getRequestMethod() : string | ||
{ | ||
return $this->processData['request method'] ?? '-'; | ||
} | ||
|
||
public function getRequestUri() : string | ||
{ | ||
return $this->processData['request URI'] ?? '-'; | ||
} | ||
|
||
public function getContentLength() : int | ||
{ | ||
return $this->processData['content length'] ?? 0; | ||
} | ||
|
||
public function getUser() : string | ||
{ | ||
return $this->processData['user'] ?? '-'; | ||
} | ||
|
||
public function getScript() : string | ||
{ | ||
return $this->processData['script'] ?? '-'; | ||
} | ||
|
||
public function getLastRequestCpu() : float | ||
{ | ||
return $this->processData['last request cpu'] ?? 0.0; | ||
} | ||
|
||
public function getLastRequestMemory() : int | ||
{ | ||
return $this->processData['last request memory'] ?? 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace hollodotme\FastCGI\Responses\PhpFpm; | ||
|
||
use DateTimeImmutable; | ||
|
||
final class Status | ||
{ | ||
/** @var array */ | ||
private $statusData; | ||
|
||
public function __construct( array $statusData ) | ||
{ | ||
$this->statusData = $statusData; | ||
} | ||
|
||
public function getPoolName() : string | ||
{ | ||
return $this->statusData['pool']; | ||
} | ||
|
||
public function getProcessManager() : string | ||
{ | ||
return $this->statusData['process manager']; | ||
} | ||
|
||
public function getStartTime() : DateTimeImmutable | ||
{ | ||
return $this->statusData['start time']; | ||
} | ||
|
||
public function getStartSince() : int | ||
{ | ||
return $this->statusData['start since']; | ||
} | ||
|
||
public function getAcceptedConnections() : int | ||
{ | ||
return $this->statusData['accepted conn']; | ||
} | ||
|
||
public function getListenQueue() : int | ||
{ | ||
return $this->statusData['listen queue']; | ||
} | ||
|
||
public function getMaxListenQueue() : int | ||
{ | ||
return $this->statusData['max listen queue']; | ||
} | ||
|
||
public function getListenQueueLength() : int | ||
{ | ||
return $this->statusData['listen queue len']; | ||
} | ||
|
||
public function getIdleProcesses() : int | ||
{ | ||
return $this->statusData['idle processes']; | ||
} | ||
|
||
public function getActiveProcesses() : int | ||
{ | ||
return $this->statusData['active processes']; | ||
} | ||
|
||
public function getTotalProcesses() : int | ||
{ | ||
return $this->statusData['total processes']; | ||
} | ||
|
||
public function getMaxActiveProcesses() : int | ||
{ | ||
return $this->statusData['max active processes']; | ||
} | ||
|
||
public function getMaxChildrenReached() : int | ||
{ | ||
return $this->statusData['max children reached']; | ||
} | ||
|
||
public function getSlowRequests() : int | ||
{ | ||
return $this->statusData['slow requests']; | ||
} | ||
} |
Oops, something went wrong.