Skip to content

Commit a7b5e63

Browse files
authored
Merge pull request #2 from dejwCake/change-config
Change config
2 parents 190c450 + 1c940ef commit a7b5e63

File tree

10 files changed

+120
-92
lines changed

10 files changed

+120
-92
lines changed

.docker/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM php:8.4-cli
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
zip \
7+
unzip \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Install PHP extensions
11+
RUN docker-php-ext-install sockets pcntl
12+
13+
# Install Composer
14+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
15+
16+
WORKDIR /app

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,20 +596,23 @@ To run the test suite you can use the following commands:
596596

597597
```bash
598598
# To run both style and unit tests.
599-
composer test
599+
docker compose exec -it app composer install
600+
601+
# To run both style and unit tests.
602+
docker compose exec -it app composer test
600603

601604
# To run only style tests.
602-
composer test:style
605+
docker compose exec -it app composer test:style
603606

604607
# To run only unit tests.
605-
composer test:unit
608+
docker compose exec -it app composer test:unit
606609
```
607610

608611
If you receive any errors from the style tests, you can automatically fix most,
609612
if not all the issues with the following command:
610613

611614
```bash
612-
composer fix:style
615+
docker compose exec -it php composer fix:style
613616
```
614617

615618
## Contribution

docker-compose.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
version: '3.7'
2-
31
services:
42

3+
app:
4+
build:
5+
context: .
6+
dockerfile: .docker/app/Dockerfile
7+
environment:
8+
HOST: rabbitmq
9+
PORT: 5672
10+
volumes:
11+
- .:/app
12+
working_dir: /app
13+
tty: true
14+
stdin_open: true
15+
depends_on:
16+
- rabbitmq
17+
518
rabbitmq:
619
image: rabbitmq:3.8
720
environment:
@@ -17,8 +30,6 @@ services:
1730
- "./tests/files/rootCA.pem:/rootCA.pem:ro"
1831
- "./tests/files/rootCA.key:/rootCA.key:ro"
1932
ports:
20-
- "15671:15671"
21-
- "15672:15672"
2233
- "5671:5671"
2334
- "5672:5672"
2435

@@ -39,5 +50,3 @@ services:
3950
ports:
4051
- 15671:15671
4152
- 15672:15672
42-
- 5671:5671
43-
- 5672:5672

src/Queue/RabbitMQQueue.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ class RabbitMQQueue extends Queue implements QueueContract, RabbitMQQueueContrac
6262
/**
6363
* Holds the Configuration
6464
*/
65-
protected QueueConfig $config;
65+
protected QueueConfig $rabbitMQConfig;
6666

6767
/**
6868
* RabbitMQQueue constructor.
6969
*/
7070
public function __construct(QueueConfig $config)
7171
{
72-
$this->config = $config;
72+
$this->rabbitMQConfig = $config;
7373
$this->dispatchAfterCommit = $config->isDispatchAfterCommit();
7474
}
7575

@@ -293,7 +293,7 @@ public function setConnection(AbstractConnection $connection): RabbitMQQueue
293293
*/
294294
public function getJobClass(): string
295295
{
296-
$job = $this->getConfig()->getAbstractJob();
296+
$job = $this->getRabbitMQConfig()->getAbstractJob();
297297

298298
throw_if(
299299
! is_a($job, RabbitMQJob::class, true),
@@ -309,7 +309,7 @@ public function getJobClass(): string
309309
*/
310310
public function getQueue($queue = null): string
311311
{
312-
return $queue ?: $this->getConfig()->getQueue();
312+
return $queue ?: $this->getRabbitMQConfig()->getQueue();
313313
}
314314

315315
/**
@@ -523,7 +523,7 @@ protected function createMessage($payload, int $attempts = 0): array
523523
$properties['correlation_id'] = $correlationId;
524524
}
525525

526-
if ($this->getConfig()->isPrioritizeDelayed()) {
526+
if ($this->getRabbitMQConfig()->isPrioritizeDelayed()) {
527527
$properties['priority'] = $attempts;
528528
}
529529

@@ -605,16 +605,16 @@ protected function getQueueArguments(string $destination): array
605605
// Messages with a priority which is higher than the queue's maximum, are treated as if they were
606606
// published with the maximum priority.
607607
// Quorum queues does not support priority.
608-
if ($this->getConfig()->isPrioritizeDelayed() && ! $this->getConfig()->isQuorum()) {
609-
$arguments['x-max-priority'] = $this->getConfig()->getQueueMaxPriority();
608+
if ($this->getRabbitMQConfig()->isPrioritizeDelayed() && ! $this->getRabbitMQConfig()->isQuorum()) {
609+
$arguments['x-max-priority'] = $this->getRabbitMQConfig()->getQueueMaxPriority();
610610
}
611611

612-
if ($this->getConfig()->isRerouteFailed()) {
612+
if ($this->getRabbitMQConfig()->isRerouteFailed()) {
613613
$arguments['x-dead-letter-exchange'] = $this->getFailedExchange();
614614
$arguments['x-dead-letter-routing-key'] = $this->getFailedRoutingKey($destination);
615615
}
616616

617-
if ($this->getConfig()->isQuorum()) {
617+
if ($this->getRabbitMQConfig()->isQuorum()) {
618618
$arguments['x-queue-type'] = 'quorum';
619619
}
620620

@@ -639,7 +639,7 @@ protected function getDelayQueueArguments(string $destination, int $ttl): array
639639
*/
640640
protected function getExchange(?string $exchange = null): string
641641
{
642-
return $exchange ?? $this->getConfig()->getExchange();
642+
return $exchange ?? $this->getRabbitMQConfig()->getExchange();
643643
}
644644

645645
/**
@@ -648,15 +648,15 @@ protected function getExchange(?string $exchange = null): string
648648
*/
649649
protected function getRoutingKey(string $destination): string
650650
{
651-
return ltrim(sprintf($this->getConfig()->getExchangeRoutingKey(), $destination), '.');
651+
return ltrim(sprintf($this->getRabbitMQConfig()->getExchangeRoutingKey(), $destination), '.');
652652
}
653653

654654
/**
655655
* Get the exchangeType, or AMQPExchangeType::DIRECT as default.
656656
*/
657657
protected function getExchangeType(?string $type = null): string
658658
{
659-
$constant = AMQPExchangeType::class.'::'.Str::upper($type ?: $this->getConfig()->getExchangeType());
659+
$constant = AMQPExchangeType::class.'::'.Str::upper($type ?: $this->getRabbitMQConfig()->getExchangeType());
660660

661661
return defined($constant) ? constant($constant) : AMQPExchangeType::DIRECT;
662662
}
@@ -666,7 +666,7 @@ protected function getExchangeType(?string $type = null): string
666666
*/
667667
protected function getFailedExchange(?string $exchange = null): string
668668
{
669-
return $exchange ?? $this->getConfig()->getFailedExchange();
669+
return $exchange ?? $this->getRabbitMQConfig()->getFailedExchange();
670670
}
671671

672672
/**
@@ -675,7 +675,7 @@ protected function getFailedExchange(?string $exchange = null): string
675675
*/
676676
protected function getFailedRoutingKey(string $destination): string
677677
{
678-
return ltrim(sprintf($this->getConfig()->getFailedRoutingKey(), $destination), '.');
678+
return ltrim(sprintf($this->getRabbitMQConfig()->getFailedRoutingKey(), $destination), '.');
679679
}
680680

681681
/**
@@ -735,9 +735,9 @@ protected function publishProperties($queue, array $options = []): array
735735
return [$destination, $exchange, $exchangeType, $attempts];
736736
}
737737

738-
protected function getConfig(): QueueConfig
738+
protected function getRabbitMQConfig(): QueueConfig
739739
{
740-
return $this->config;
740+
return $this->rabbitMQConfig;
741741
}
742742

743743
/**

tests/Feature/ConnectorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase
1414
{
15-
public function test_lazy_connection(): void
15+
public function testLazyConnection(): void
1616
{
1717
$this->app['config']->set('queue.connections.rabbitmq', [
1818
'driver' => 'rabbitmq',
@@ -55,7 +55,7 @@ public function test_lazy_connection(): void
5555
$this->assertTrue($connection->getConnection()->isConnected());
5656
}
5757

58-
public function test_lazy_stream_connection(): void
58+
public function testLazyStreamConnection(): void
5959
{
6060
$this->app['config']->set('queue.connections.rabbitmq', [
6161
'driver' => 'rabbitmq',
@@ -98,7 +98,7 @@ public function test_lazy_stream_connection(): void
9898
$this->assertTrue($connection->getConnection()->isConnected());
9999
}
100100

101-
public function test_ssl_connection(): void
101+
public function testSslConnection(): void
102102
{
103103
$this->markTestSkipped();
104104

@@ -142,7 +142,7 @@ public function test_ssl_connection(): void
142142
}
143143

144144
// Test to validate ssl connection params
145-
public function test_no_verification_ssl_connection(): void
145+
public function testNoVerificationSslConnection(): void
146146
{
147147
$this->app['config']->set('queue.connections.rabbitmq', [
148148
'driver' => 'rabbitmq',

tests/Feature/QueueTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ protected function setUp(): void
2020
]);
2121
}
2222

23-
public function test_connection(): void
23+
public function testConnection(): void
2424
{
2525
$this->assertInstanceOf(AMQPStreamConnection::class, $this->connection()->getChannel()->getConnection());
2626
}
2727

28-
public function test_without_reconnect(): void
28+
public function testWithoutReconnect(): void
2929
{
3030
$queue = $this->connection('rabbitmq');
3131

tests/Feature/SslQueueTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function getEnvironmentSetUp($app): void
4343
]);
4444
}
4545

46-
public function test_connection(): void
46+
public function testConnection(): void
4747
{
4848
$this->assertInstanceOf(AMQPSSLConnection::class, $this->connection()->getChannel()->getConnection());
4949
}

0 commit comments

Comments
 (0)