Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/Worker/Transport/Command/Client/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Temporal\Worker\Transport\Command\Common\RequestTrait;
use Temporal\Worker\Transport\Command\RequestInterface;

\define(['REQUEST_START_ID'][0], (int) (\microtime(true) * 1_000_000.0));

/**
* Carries request to perform host action with payloads and failure as context. Can be cancelled if allows
*
Expand All @@ -27,7 +29,7 @@ class Request implements RequestInterface
{
use RequestTrait;

protected static int $lastID = 9000;
protected static int $lastID = REQUEST_START_ID;
protected int $id;
protected ValuesInterface $payloads;
protected HeaderInterface $header;
Expand Down Expand Up @@ -65,12 +67,12 @@ public function getFailure(): ?\Throwable

private function getNextID(): int
{
$next = ++static::$lastID;
++static::$lastID;

if ($next >= \PHP_INT_MAX) {
$next = static::$lastID = 1;
if (static::$lastID === \PHP_INT_MAX) {
static::$lastID = 1;
}

return $next;
return static::$lastID;
}
}
2 changes: 1 addition & 1 deletion tests/Fixtures/CommandResetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class CommandResetter extends Request
{
public static function reset()
public static function reset(): void
{
self::$lastID = 9000;
}
Expand Down
Loading