File tree Expand file tree Collapse file tree
src/Worker/Transport/Command/Client Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818use Temporal \Worker \Transport \Command \Common \RequestTrait ;
1919use Temporal \Worker \Transport \Command \RequestInterface ;
2020
21+ \define (['REQUEST_START_ID ' ][0 ], (int ) (\microtime (true ) * 1_000_000.0 ));
22+
2123/**
2224 * Carries request to perform host action with payloads and failure as context. Can be cancelled if allows
2325 *
@@ -27,7 +29,7 @@ class Request implements RequestInterface
2729{
2830 use RequestTrait;
2931
30- protected static int $ lastID = 9000 ;
32+ protected static int $ lastID = REQUEST_START_ID ;
3133 protected int $ id ;
3234 protected ValuesInterface $ payloads ;
3335 protected HeaderInterface $ header ;
@@ -63,9 +65,14 @@ public function getFailure(): ?\Throwable
6365 return $ this ->failure ;
6466 }
6567
66- protected function getNextID (): int
68+ private function getNextID (): int
6769 {
68- static ::$ lastID = (static ::$ lastID + 1 ) % 1_000_000 ;
69- return \time () * 1_000_000 + static ::$ lastID ;
70+ ++static ::$ lastID ;
71+
72+ if (static ::$ lastID === \PHP_INT_MAX ) {
73+ static ::$ lastID = 1 ;
74+ }
75+
76+ return static ::$ lastID ;
7077 }
7178}
Original file line number Diff line number Diff line change @@ -19,15 +19,4 @@ public static function reset(): void
1919 {
2020 self ::$ lastID = 9000 ;
2121 }
22-
23- protected function getNextID (): int
24- {
25- $ next = ++static ::$ lastID ;
26-
27- if ($ next >= \PHP_INT_MAX ) {
28- $ next = static ::$ lastID = 1 ;
29- }
30-
31- return $ next ;
32- }
3322}
You can’t perform that action at this time.
0 commit comments