Skip to content
Merged
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
10 changes: 2 additions & 8 deletions src/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ public function consume(

$timeoutWatcher = $config->pollInterval->isPositive()
? new Internal\TimeoutWatcher($polls, $config->pollInterval)
: null;
: throw new \LogicException('Pooling is required. Set $pollInterval to a positive value.');

if ($timeoutWatcher !== null) {
$watchers[] = $timeoutWatcher;
}
$watchers[] = $timeoutWatcher;

if ($config->listenForInserts) {
$channelName = $queue->enableNotifyInsert();
Expand All @@ -58,10 +56,6 @@ public function consume(
);
}

if (\count($watchers) === 0) {
throw new \LogicException('At least one watcher must be configured. Either set a positive $pollInterval or enable $listenForInserts or both.');
}

$handle = new Internal\ConsumeHandler(
$this->pg,
$config,
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/ChannelWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
public function __construct(
private Pipeline\Queue $queue,
private PostgresListener $listener,
private ?TimeoutWatcher $timeout = null,
private TimeoutWatcher $timeout,
) {}

public function watch(): void
{
EventLoop::queue(function (): void {
foreach ($this->listener as $_) {
$this->timeout?->reschedule();
$this->timeout->reschedule();
$this->queue->pushAsync(null)->ignore();
}
});
Expand Down
2 changes: 1 addition & 1 deletion tests/PgmqTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function testInvalidConsumerConfiguration(): void
$consumer = createConsumer($this->pg);

self::expectException(\LogicException::class);
self::expectExceptionMessage('At least one watcher must be configured. Either set a positive $pollInterval or enable $listenForInserts or both.');
self::expectExceptionMessage('Pooling is required. Set $pollInterval to a positive value.');
$consumer->consume(static fn() => null, new ConsumeConfig(
queue: $queue->name,
pollInterval: TimeSpan::fromSeconds(0),
Expand Down