Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
## 1.0.0 under development

- Initial release.
- New #299: Add `hasStatusSupport()` method to `AdapterInterface` (WarLikeLaux)
Comment thread
samdark marked this conversation as resolved.
Outdated
8 changes: 8 additions & 0 deletions src/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ public function runExisting(callable $handlerCallback): void;
/**
* Returns status code of a message with the given ID.
* Returns {@see MessageStatus::NOT_FOUND} when status tracking is not supported or there is no such id.
* Use {@see hasStatusSupport()} to tell unsupported tracking apart from a missing ID.
*
* @param int|string $id ID of a message.
*/
public function status(string|int $id): MessageStatus;

/**
* Whether the adapter supports message status tracking.
*
* When `false`, {@see status()} always returns {@see MessageStatus::NOT_FOUND}.
*/
public function hasStatusSupport(): bool;

/**
* Pushing a message to the queue. Adapter sets message ID if available.
*/
Expand Down
5 changes: 5 additions & 0 deletions stubs/InMemoryAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ public function status(int|string $id): MessageStatus

return MessageStatus::NOT_FOUND;
}

public function hasStatusSupport(): bool
{
return true;
}
}
5 changes: 5 additions & 0 deletions tests/App/FakeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public function status(string|int $id): MessageStatus
throw new Exception('`status()` method is not implemented yet.');
}

public function hasStatusSupport(): bool
{
return false;
}

public function subscribe(callable $handlerCallback): void
{
throw new Exception('`subscribe()` method is not implemented yet.');
Expand Down
5 changes: 5 additions & 0 deletions tests/Benchmark/Support/VoidAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function status(int|string $id): MessageStatus
throw new InvalidArgumentException();
}

public function hasStatusSupport(): bool
{
return false;
}

public function push(MessageInterface $message): MessageInterface
{
$this->serializer->serialize($message);
Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/Stubs/InMemoryAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public function testPush(): void
$this->assertSame('c', $envelope3->getMessage()->getData());
}

public function testHasStatusSupport(): void
{
$adapter = new InMemoryAdapter();

$this->assertTrue($adapter->hasStatusSupport());
}

public function testStatusWaitingForPushedMessage(): void
{
$adapter = new InMemoryAdapter();
Expand Down
Loading