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
18 changes: 14 additions & 4 deletions src/Worker/Transport/Command/Client/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public function __construct(
$this->id = $this->getNextID();
}

/**
* @internal
*/
public static function resetLastId(int $lastID): void
{
self::$lastID = $lastID;
}

public function getID(): int
{
return $this->id;
Expand All @@ -65,12 +73,14 @@ 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;
}
}

Request::resetLastId((int) (\microtime(true) * 1_000_000.0));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put it somewhere after worker (php process) bootstrap, but need time to think / test

22 changes: 0 additions & 22 deletions tests/Fixtures/CommandResetter.php

This file was deleted.

3 changes: 2 additions & 1 deletion tests/Fixtures/WorkerMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Temporal\DataConverter\DataConverter;
use Temporal\Exception\Failure\FailureConverter;
use Temporal\Tests\TestCase;
use Temporal\Worker\Transport\Command\Client\Request;
use Temporal\Worker\Transport\HostConnectionInterface;
use Temporal\Worker\WorkerFactoryInterface;
use Temporal\WorkerFactory;
Expand Down Expand Up @@ -45,7 +46,7 @@ public static function createMock(): WorkerMock
$mock->factory = WorkerFactory::create();
$mock->registerWorkflowAndActivities();

CommandResetter::reset();
Request::resetLastId(9000);

return $mock;
}
Expand Down
Loading