Skip to content

Commit 33a6d00

Browse files
committed
minor #42245 [Messenger] [Redis] Remove BC layer around delete_after_ack option (chalasr)
This PR was merged into the 6.0 branch. Discussion ---------- [Messenger] [Redis] Remove BC layer around `delete_after_ack` option | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- baae384 [Messenger][Redis] Remove BC layer around `delete_after_ack` option
2 parents 658df80 + baae384 commit 33a6d00

File tree

5 files changed

+35
-53
lines changed

5 files changed

+35
-53
lines changed

src/Symfony/Component/Messenger/Bridge/Redis/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* Remove option `tls`
88
* Using invalid options will throw a `LogicException`
9+
* The `delete_after_ack` config option now defaults to `true`
910

1011
5.4
1112
---

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testFromInvalidDsn()
6161
public function testFromDsn()
6262
{
6363
$this->assertEquals(
64-
new Connection(['stream' => 'queue', 'delete_after_ack' => true], [
64+
new Connection(['stream' => 'queue'], [
6565
'host' => 'localhost',
6666
'port' => 6379,
6767
]),
@@ -80,32 +80,32 @@ public function testFromDsnWithMultipleHosts()
8080
}, $hosts);
8181
$dsn = implode(',', $dsn);
8282

83-
$this->assertInstanceOf(Connection::class, Connection::fromDsn($dsn, ['delete_after_ack' => true]));
83+
$this->assertInstanceOf(Connection::class, Connection::fromDsn($dsn));
8484
}
8585

8686
public function testFromDsnOnUnixSocket()
8787
{
8888
$this->assertEquals(
89-
new Connection(['stream' => 'queue', 'delete_after_ack' => true], [
89+
new Connection(['stream' => 'queue'], [
9090
'host' => '/var/run/redis/redis.sock',
9191
'port' => 0,
9292
], [], $redis = $this->createMock(\Redis::class)),
93-
Connection::fromDsn('redis:///var/run/redis/redis.sock', ['stream' => 'queue', 'delete_after_ack' => true], $redis)
93+
Connection::fromDsn('redis:///var/run/redis/redis.sock', ['stream' => 'queue'], $redis)
9494
);
9595
}
9696

9797
public function testFromDsnWithOptions()
9898
{
9999
$this->assertEquals(
100-
Connection::fromDsn('redis://localhost', ['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1', 'auto_setup' => false, 'serializer' => 2, 'delete_after_ack' => true]),
100+
Connection::fromDsn('redis://localhost', ['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1', 'auto_setup' => false, 'serializer' => 2]),
101101
Connection::fromDsn('redis://localhost/queue/group1/consumer1?serializer=2&auto_setup=0&delete_after_ack=1')
102102
);
103103
}
104104

105105
public function testFromDsnWithOptionsAndTrailingSlash()
106106
{
107107
$this->assertEquals(
108-
Connection::fromDsn('redis://localhost/', ['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1', 'auto_setup' => false, 'serializer' => 2, 'delete_after_ack' => true]),
108+
Connection::fromDsn('redis://localhost/', ['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1', 'auto_setup' => false, 'serializer' => 2]),
109109
Connection::fromDsn('redis://localhost/queue/group1/consumer1?serializer=2&auto_setup=0&delete_after_ack=1')
110110
);
111111
}
@@ -124,7 +124,7 @@ public function testFromDsnWithRedissScheme()
124124
public function testFromDsnWithQueryOptions()
125125
{
126126
$this->assertEquals(
127-
new Connection(['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1', 'delete_after_ack' => true], [
127+
new Connection(['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1'], [
128128
'host' => 'localhost',
129129
'port' => 6379,
130130
], [
@@ -137,12 +137,12 @@ public function testFromDsnWithQueryOptions()
137137
public function testFromDsnWithMixDsnQueryOptions()
138138
{
139139
$this->assertEquals(
140-
Connection::fromDsn('redis://localhost/queue/group1?serializer=2', ['consumer' => 'specific-consumer', 'delete_after_ack' => true]),
140+
Connection::fromDsn('redis://localhost/queue/group1?serializer=2', ['consumer' => 'specific-consumer']),
141141
Connection::fromDsn('redis://localhost/queue/group1/specific-consumer?serializer=2&delete_after_ack=1')
142142
);
143143

144144
$this->assertEquals(
145-
Connection::fromDsn('redis://localhost/queue/group1/consumer1', ['consumer' => 'specific-consumer', 'delete_after_ack' => true]),
145+
Connection::fromDsn('redis://localhost/queue/group1/consumer1', ['consumer' => 'specific-consumer']),
146146
Connection::fromDsn('redis://localhost/queue/group1/consumer1?delete_after_ack=1')
147147
);
148148
}
@@ -163,7 +163,7 @@ public function testKeepGettingPendingMessages()
163163
->with('symfony', 'consumer', ['queue' => 0], 1, null)
164164
->willReturn(['queue' => [['message' => '{"body":"Test","headers":[]}']]]);
165165

166-
$connection = Connection::fromDsn('redis://localhost/queue', ['delete_after_ack' => true], $redis);
166+
$connection = Connection::fromDsn('redis://localhost/queue', [], $redis);
167167
$this->assertNotNull($connection->get());
168168
$this->assertNotNull($connection->get());
169169
$this->assertNotNull($connection->get());
@@ -177,7 +177,7 @@ public function testAuth()
177177
->with('password')
178178
->willReturn(true);
179179

180-
Connection::fromDsn('redis://password@localhost/queue', ['delete_after_ack' => true], $redis);
180+
Connection::fromDsn('redis://password@localhost/queue', [], $redis);
181181
}
182182

183183
public function testAuthFromOptions()
@@ -188,7 +188,7 @@ public function testAuthFromOptions()
188188
->with('password')
189189
->willReturn(true);
190190

191-
Connection::fromDsn('redis://localhost/queue', ['auth' => 'password', 'delete_after_ack' => true], $redis);
191+
Connection::fromDsn('redis://localhost/queue', ['auth' => 'password'], $redis);
192192
}
193193

194194
public function testAuthFromOptionsAndDsn()
@@ -199,7 +199,7 @@ public function testAuthFromOptionsAndDsn()
199199
->with('password2')
200200
->willReturn(true);
201201

202-
Connection::fromDsn('redis://password1@localhost/queue', ['auth' => 'password2', 'delete_after_ack' => true], $redis);
202+
Connection::fromDsn('redis://password1@localhost/queue', ['auth' => 'password2'], $redis);
203203
}
204204

205205
public function testNoAuthWithEmptyPassword()
@@ -210,7 +210,7 @@ public function testNoAuthWithEmptyPassword()
210210
->with('')
211211
->willThrowException(new \RuntimeException());
212212

213-
Connection::fromDsn('redis://@localhost/queue', ['delete_after_ack' => true], $redis);
213+
Connection::fromDsn('redis://@localhost/queue', [], $redis);
214214
}
215215

216216
public function testAuthZeroPassword()
@@ -221,7 +221,7 @@ public function testAuthZeroPassword()
221221
->with('0')
222222
->willReturn(true);
223223

224-
Connection::fromDsn('redis://0@localhost/queue', ['delete_after_ack' => true], $redis);
224+
Connection::fromDsn('redis://0@localhost/queue', [], $redis);
225225
}
226226

227227
public function testFailedAuth()
@@ -234,14 +234,14 @@ public function testFailedAuth()
234234
->with('password')
235235
->willReturn(false);
236236

237-
Connection::fromDsn('redis://password@localhost/queue', ['delete_after_ack' => true], $redis);
237+
Connection::fromDsn('redis://password@localhost/queue', [], $redis);
238238
}
239239

240240
public function testDbIndex()
241241
{
242242
$redis = new \Redis();
243243

244-
Connection::fromDsn('redis://localhost/queue?dbindex=2', ['delete_after_ack' => true], $redis);
244+
Connection::fromDsn('redis://localhost/queue?dbindex=2', [], $redis);
245245

246246
$this->assertSame(2, $redis->getDbNum());
247247
}
@@ -254,7 +254,7 @@ public function testGetPendingMessageFirst()
254254
->with('symfony', 'consumer', ['queue' => '0'], 1, null)
255255
->willReturn(['queue' => [['message' => '{"body":"1","headers":[]}']]]);
256256

257-
$connection = Connection::fromDsn('redis://localhost/queue', ['delete_after_ack' => true], $redis);
257+
$connection = Connection::fromDsn('redis://localhost/queue', [], $redis);
258258
$connection->get();
259259
}
260260

@@ -280,7 +280,7 @@ public function testClaimAbandonedMessageWithRaceCondition()
280280
->with('queue', 'symfony', 'consumer', 3600000, ['redisid-123'], ['JUSTID'])
281281
->willReturn([]);
282282

283-
$connection = Connection::fromDsn('redis://localhost/queue', ['delete_after_ack' => true], $redis);
283+
$connection = Connection::fromDsn('redis://localhost/queue', [], $redis);
284284
$connection->get();
285285
}
286286

@@ -308,7 +308,7 @@ public function testClaimAbandonedMessage()
308308
->with('queue', 'symfony', 'consumer', 3600000, ['redisid-123'], ['JUSTID'])
309309
->willReturn([]);
310310

311-
$connection = Connection::fromDsn('redis://localhost/queue', ['delete_after_ack' => true], $redis);
311+
$connection = Connection::fromDsn('redis://localhost/queue', [], $redis);
312312
$connection->get();
313313
}
314314

@@ -320,22 +320,22 @@ public function testUnexpectedRedisError()
320320
$redis->expects($this->once())->method('xreadgroup')->willReturn(false);
321321
$redis->expects($this->once())->method('getLastError')->willReturn('Redis error happens');
322322

323-
$connection = Connection::fromDsn('redis://localhost/queue', ['auto_setup' => false, 'delete_after_ack' => true], $redis);
323+
$connection = Connection::fromDsn('redis://localhost/queue', ['auto_setup' => false], $redis);
324324
$connection->get();
325325
}
326326

327327
public function testGetAfterReject()
328328
{
329329
$redis = new \Redis();
330-
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', ['delete_after_ack' => true], $redis);
330+
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', [], $redis);
331331

332332
$connection->add('1', []);
333333
$connection->add('2', []);
334334

335335
$failing = $connection->get();
336336
$connection->reject($failing['id']);
337337

338-
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', ['delete_after_ack' => true]);
338+
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget');
339339
$this->assertNotNull($connection->get());
340340

341341
$redis->del('messenger-rejectthenget');
@@ -345,7 +345,7 @@ public function testGetNonBlocking()
345345
{
346346
$redis = new \Redis();
347347

348-
$connection = Connection::fromDsn('redis://localhost/messenger-getnonblocking', ['delete_after_ack' => true], $redis);
348+
$connection = Connection::fromDsn('redis://localhost/messenger-getnonblocking', [], $redis);
349349

350350
$this->assertNull($connection->get()); // no message, should return null immediately
351351
$connection->add('1', []);
@@ -357,7 +357,7 @@ public function testGetNonBlocking()
357357
public function testJsonError()
358358
{
359359
$redis = new \Redis();
360-
$connection = Connection::fromDsn('redis://localhost/json-error', ['delete_after_ack' => true], $redis);
360+
$connection = Connection::fromDsn('redis://localhost/json-error', [], $redis);
361361
try {
362362
$connection->add("\xB1\x31", []);
363363
} catch (TransportException $e) {
@@ -374,7 +374,7 @@ public function testMaxEntries()
374374
->with('queue', '*', ['message' => '{"body":"1","headers":[]}'], 20000, true)
375375
->willReturn(1);
376376

377-
$connection = Connection::fromDsn('redis://localhost/queue?stream_max_entries=20000', ['delete_after_ack' => true], $redis);
377+
$connection = Connection::fromDsn('redis://localhost/queue?stream_max_entries=20000', [], $redis);
378378
$connection->add('1', []);
379379
}
380380

@@ -393,16 +393,6 @@ public function testDeleteAfterAck()
393393
$connection->ack('1');
394394
}
395395

396-
/**
397-
* @group legacy
398-
*/
399-
public function testLegacyOmitDeleteAfterAck()
400-
{
401-
$this->expectDeprecation('Since symfony/redis-messenger 5.4: Not setting the "delete_after_ack" boolean option explicitly is deprecated, its default value will change to true in 6.0.');
402-
403-
Connection::fromDsn('redis://localhost/queue');
404-
}
405-
406396
public function testDeleteAfterReject()
407397
{
408398
$redis = $this->createMock(\Redis::class);
@@ -414,7 +404,7 @@ public function testDeleteAfterReject()
414404
->with('queue', ['1'])
415405
->willReturn(1);
416406

417-
$connection = Connection::fromDsn('redis://localhost/queue?delete_after_reject=true', ['delete_after_ack' => true], $redis);
407+
$connection = Connection::fromDsn('redis://localhost/queue?delete_after_reject=true', [], $redis);
418408
$connection->reject('1');
419409
}
420410

@@ -428,7 +418,7 @@ public function testLastErrorGetsCleared()
428418
$redis->method('getLastError')->willReturnOnConsecutiveCalls('xadd error', 'xack error');
429419
$redis->expects($this->exactly(2))->method('clearLastError');
430420

431-
$connection = Connection::fromDsn('redis://localhost/messenger-clearlasterror', ['auto_setup' => false, 'delete_after_ack' => true], $redis);
421+
$connection = Connection::fromDsn('redis://localhost/messenger-clearlasterror', ['auto_setup' => false], $redis);
432422

433423
try {
434424
$connection->add('message', []);
@@ -448,7 +438,7 @@ public function testLastErrorGetsCleared()
448438
public function testLazy()
449439
{
450440
$redis = new \Redis();
451-
$connection = Connection::fromDsn('redis://localhost/messenger-lazy?lazy=1', ['delete_after_ack' => true], $redis);
441+
$connection = Connection::fromDsn('redis://localhost/messenger-lazy?lazy=1', [], $redis);
452442

453443
$connection->add('1', []);
454444
$this->assertNotEmpty($message = $connection->get());
@@ -464,7 +454,7 @@ public function testLazyCluster()
464454
$connection = new Connection(
465455
['lazy' => true],
466456
['host' => explode(' ', getenv('REDIS_CLUSTER_HOSTS'))],
467-
['delete_after_ack' => true]
457+
[]
468458
);
469459

470460
$connection->add('1', []);

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp(): void
3333

3434
try {
3535
$this->redis = new \Redis();
36-
$this->connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), ['delete_after_ack' => true], $this->redis);
36+
$this->connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), [], $this->redis);
3737
$this->connection->cleanup();
3838
$this->connection->setup();
3939
} catch (\Exception $e) {
@@ -109,7 +109,7 @@ public function testConnectionSendDelayedMessagesWithSameContent()
109109
public function testConnectionBelowRedeliverTimeout()
110110
{
111111
// lower redeliver timeout and claim interval
112-
$connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), ['delete_after_ack' => true], $this->redis);
112+
$connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), [], $this->redis);
113113

114114
$connection->cleanup();
115115
$connection->setup();
@@ -137,7 +137,7 @@ public function testConnectionClaimAndRedeliver()
137137
// lower redeliver timeout and claim interval
138138
$connection = Connection::fromDsn(
139139
getenv('MESSENGER_REDIS_DSN'),
140-
['redeliver_timeout' => 0, 'claim_interval' => 500, 'delete_after_ack' => true],
140+
['redeliver_timeout' => 0, 'claim_interval' => 500],
141141
$this->redis
142142
);
143143

src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Connection
3232
'group' => 'symfony',
3333
'consumer' => 'consumer',
3434
'auto_setup' => true,
35-
'delete_after_ack' => false,
35+
'delete_after_ack' => true,
3636
'delete_after_reject' => true,
3737
'stream_max_entries' => 0, // any value higher than 0 defines an approximate maximum number of stream entries
3838
'dbindex' => 0,
@@ -175,8 +175,6 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis|\Re
175175
if (\array_key_exists('delete_after_ack', $redisOptions)) {
176176
$deleteAfterAck = filter_var($redisOptions['delete_after_ack'], \FILTER_VALIDATE_BOOLEAN);
177177
unset($redisOptions['delete_after_ack']);
178-
} else {
179-
trigger_deprecation('symfony/redis-messenger', '5.4', 'Not setting the "delete_after_ack" boolean option explicitly is deprecated, its default value will change to true in 6.0.');
180178
}
181179

182180
$deleteAfterReject = null;

src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@ public function __construct(?string $globalFailureReceiverName, ServiceProviderI
5050
parent::__construct();
5151
}
5252

53-
protected function getReceiverName(): string
54-
{
55-
trigger_deprecation('symfony/messenger', '5.3', 'The method "%s()" is deprecated, use getGlobalFailureReceiverName() instead.', __METHOD__);
56-
57-
return $this->globalFailureReceiverName;
58-
}
59-
6053
protected function getGlobalFailureReceiverName(): ?string
6154
{
6255
return $this->globalFailureReceiverName;

0 commit comments

Comments
 (0)