-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from FluffyDiscord/#why-not-count
Feat: add callback to check how many workers are available
- Loading branch information
Showing
4 changed files
with
173 additions
and
2 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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spiral\RoadRunner\Informer; | ||
|
||
final class Worker | ||
{ | ||
/** | ||
* @param positive-int $pid process id | ||
* @param int $statusCode integer status of the worker | ||
* @param int $executions number of worker executions | ||
* @param positive-int $createdAt unix nano timestamp of worker creation time | ||
* @param positive-int $memoryUsage memory usage in bytes. Values might vary for different operating systems and based on RSS | ||
* @param float $cpuUsage how many percent of the CPU time this process uses | ||
* @param string $command used in the service plugin and shows a command for the particular service | ||
*/ | ||
public function __construct( | ||
public int $pid, | ||
public int $statusCode, | ||
public int $executions, | ||
public int $createdAt, | ||
public int $memoryUsage, | ||
public float $cpuUsage, | ||
public string $command, | ||
public string $status, | ||
) { | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Spiral\RoadRunner\Informer; | ||
|
||
final class Workers implements \Countable | ||
{ | ||
/** | ||
* @param array<Worker> $workers | ||
*/ | ||
public function __construct( | ||
public array $workers = [], | ||
) { | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return \count($this->workers); | ||
} | ||
} |
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
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