diff --git a/src/Worker/Transport/Command/Client/Request.php b/src/Worker/Transport/Command/Client/Request.php index d39819961..8da82a2f1 100644 --- a/src/Worker/Transport/Command/Client/Request.php +++ b/src/Worker/Transport/Command/Client/Request.php @@ -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 * @@ -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; @@ -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; } } diff --git a/tests/Fixtures/CommandResetter.php b/tests/Fixtures/CommandResetter.php index afb13f529..244ae0ff2 100644 --- a/tests/Fixtures/CommandResetter.php +++ b/tests/Fixtures/CommandResetter.php @@ -15,7 +15,7 @@ class CommandResetter extends Request { - public static function reset() + public static function reset(): void { self::$lastID = 9000; }