Skip to content

Commit bc99baa

Browse files
author
Henning
committed
change option name
1 parent d69f276 commit bc99baa

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

pkg/dbal/DbalContext.php

+5-13
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,21 @@ class DbalContext implements Context
3939
* Callable must return instance of Doctrine\DBAL\Connection once called.
4040
*
4141
* @param Connection|callable $connection
42-
* @param array $config
4342
*/
4443
public function __construct($connection, array $config = [])
4544
{
4645
$this->config = array_replace([
4746
'table_name' => 'enqueue',
4847
'polling_interval' => null,
49-
'subscription_interval' => null,
48+
'subscription_polling_interval' => null,
5049
], $config);
5150

5251
if ($connection instanceof Connection) {
5352
$this->connection = $connection;
5453
} elseif (is_callable($connection)) {
5554
$this->connectionFactory = $connection;
5655
} else {
57-
throw new \InvalidArgumentException(sprintf(
58-
'The connection argument must be either %s or callable that returns %s.',
59-
Connection::class,
60-
Connection::class
61-
));
56+
throw new \InvalidArgumentException(sprintf('The connection argument must be either %s or callable that returns %s.', Connection::class, Connection::class));
6257
}
6358
}
6459

@@ -136,8 +131,8 @@ public function createSubscriptionConsumer(): SubscriptionConsumer
136131
$consumer->setRedeliveryDelay($this->config['redelivery_delay']);
137132
}
138133

139-
if (isset($this->config['subscription_interval'])) {
140-
$consumer->setSubscriptionInterval($this->config['subscription_interval']);
134+
if (isset($this->config['subscription_polling_interval'])) {
135+
$consumer->setPollingInterval($this->config['subscription_polling_interval']);
141136
}
142137

143138
return $consumer;
@@ -207,10 +202,7 @@ public function getDbalConnection(): Connection
207202
if (false == $this->connection) {
208203
$connection = call_user_func($this->connectionFactory);
209204
if (false == $connection instanceof Connection) {
210-
throw new \LogicException(sprintf(
211-
'The factory must return instance of Doctrine\DBAL\Connection. It returns %s',
212-
is_object($connection) ? get_class($connection) : gettype($connection)
213-
));
205+
throw new \LogicException(sprintf('The factory must return instance of Doctrine\DBAL\Connection. It returns %s', is_object($connection) ? get_class($connection) : gettype($connection)));
214206
}
215207

216208
$this->connection = $connection;

pkg/dbal/DbalSubscriptionConsumer.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ class DbalSubscriptionConsumer implements SubscriptionConsumer
4141
*
4242
* @var int
4343
*/
44-
private $subscriptionInterval = 200;
44+
private $pollingInterval = 200;
4545

46-
/**
47-
* @param DbalContext $context
48-
*/
4946
public function __construct(DbalContext $context)
5047
{
5148
$this->context = $context;
@@ -70,9 +67,14 @@ public function setRedeliveryDelay(int $redeliveryDelay): self
7067
return $this;
7168
}
7269

73-
public function setSubscriptionInterval(int $subscriptionInterval): self
70+
public function getPollingInterval(): int
71+
{
72+
return $this->pollingInterval;
73+
}
74+
75+
public function setPollingInterval(int $msec): self
7476
{
75-
$this->subscriptionInterval = $subscriptionInterval;
77+
$this->pollingInterval = $msec;
7678

7779
return $this;
7880
}
@@ -116,7 +118,7 @@ public function consume(int $timeout = 0): void
116118
} else {
117119
$currentQueueNames = [];
118120

119-
usleep($this->subscriptionInterval * 1000); // 200ms
121+
usleep($this->getPollingInterval() * 1000);
120122
}
121123

122124
if ($timeout && microtime(true) >= $now + $timeout) {

pkg/dbal/Tests/DbalContextTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function testCouldBeConstructedWithEmptyConfiguration()
3939
$this->assertAttributeEquals([
4040
'table_name' => 'enqueue',
4141
'polling_interval' => null,
42+
'subscription_polling_interval' => null,
4243
], 'config', $factory);
4344
}
4445

@@ -47,11 +48,13 @@ public function testCouldBeConstructedWithCustomConfiguration()
4748
$factory = new DbalContext($this->createConnectionMock(), [
4849
'table_name' => 'theTableName',
4950
'polling_interval' => 12345,
51+
'subscription_polling_interval' => 12345,
5052
]);
5153

5254
$this->assertAttributeEquals([
5355
'table_name' => 'theTableName',
5456
'polling_interval' => 12345,
57+
'subscription_polling_interval' => 12345,
5558
], 'config', $factory);
5659
}
5760

0 commit comments

Comments
 (0)