Skip to content

Add --json flag to rabbitmq:consume command for structured logging #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Set up Docker
run: |
sudo rm /usr/local/bin/docker-compose
sudo rm -f /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
Expand Down
1 change: 1 addition & 0 deletions src/Console/ConsumeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ConsumeCommand extends WorkCommand
{--timeout=60 : The number of seconds a child process can run}
{--tries=1 : Number of times to attempt a job before logging it failed}
{--rest=0 : Number of seconds to rest between jobs}
{--json : Output the queue worker information as JSON}

{--max-priority=}
{--consumer-tag}
Expand Down
2 changes: 1 addition & 1 deletion src/Queue/Connection/ConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ConfigFactory
*/
public static function make(array $config = []): AMQPConnectionConfig
{
return tap(new AMQPConnectionConfig(), function (AMQPConnectionConfig $connectionConfig) use ($config) {
return tap(new AMQPConnectionConfig, function (AMQPConnectionConfig $connectionConfig) use ($config) {
// Set the connection to a Lazy by default
$connectionConfig->setIsLazy(! in_array(
Arr::get($config, 'lazy') ?? true,
Expand Down
2 changes: 1 addition & 1 deletion src/Queue/QueueConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class QueueConfigFactory
*/
public static function make(array $config = []): QueueConfig
{
return tap(new QueueConfig(), function (QueueConfig $queueConfig) use ($config) {
return tap(new QueueConfig, function (QueueConfig $queueConfig) use ($config) {
if (! empty($queue = Arr::get($config, 'queue'))) {
$queueConfig->setQueue($queue);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Feature/ConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase
{
public function testLazyConnection(): void
public function test_lazy_connection(): void
{
$this->app['config']->set('queue.connections.rabbitmq', [
'driver' => 'rabbitmq',
Expand Down Expand Up @@ -55,7 +55,7 @@ public function testLazyConnection(): void
$this->assertTrue($connection->getConnection()->isConnected());
}

public function testLazyStreamConnection(): void
public function test_lazy_stream_connection(): void
{
$this->app['config']->set('queue.connections.rabbitmq', [
'driver' => 'rabbitmq',
Expand Down Expand Up @@ -98,7 +98,7 @@ public function testLazyStreamConnection(): void
$this->assertTrue($connection->getConnection()->isConnected());
}

public function testSslConnection(): void
public function test_ssl_connection(): void
{
$this->markTestSkipped();

Expand Down Expand Up @@ -142,7 +142,7 @@ public function testSslConnection(): void
}

// Test to validate ssl connection params
public function testNoVerificationSslConnection(): void
public function test_no_verification_ssl_connection(): void
{
$this->app['config']->set('queue.connections.rabbitmq', [
'driver' => 'rabbitmq',
Expand Down
10 changes: 5 additions & 5 deletions tests/Feature/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class QueueTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

Expand All @@ -20,16 +20,16 @@ public function setUp(): void
]);
}

public function testConnection(): void
public function test_connection(): void
{
$this->assertInstanceOf(AMQPStreamConnection::class, $this->connection()->getChannel()->getConnection());
}

public function testWithoutReconnect(): void
public function test_without_reconnect(): void
{
$queue = $this->connection('rabbitmq');

$queue->push(new TestJob());
$queue->push(new TestJob);
sleep(1);
$this->assertSame(1, $queue->size());

Expand All @@ -38,6 +38,6 @@ public function testWithoutReconnect(): void
$this->assertFalse($queue->getConnection()->isConnected());

$this->expectException(AMQPChannelClosedException::class);
$queue->push(new TestJob());
$queue->push(new TestJob);
}
}
4 changes: 2 additions & 2 deletions tests/Feature/SslQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SslQueueTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
$this->markTestSkipped();
}
Expand Down Expand Up @@ -43,7 +43,7 @@ protected function getEnvironmentSetUp($app): void
]);
}

public function testConnection(): void
public function test_connection(): void
{
$this->assertInstanceOf(AMQPSSLConnection::class, $this->connection()->getChannel()->getConnection());
}
Expand Down
58 changes: 29 additions & 29 deletions tests/Feature/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class TestCase extends BaseTestCase
/**
* @throws AMQPProtocolChannelException
*/
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

Expand All @@ -40,17 +40,17 @@ protected function tearDown(): void
parent::tearDown();
}

public function testSizeDoesNotThrowExceptionOnUnknownQueue(): void
public function test_size_does_not_throw_exception_on_unknown_queue(): void
{
$this->assertEmpty(0, Queue::size(Str::random()));
}

public function testPopNothing(): void
public function test_pop_nothing(): void
{
$this->assertNull(Queue::pop('foo'));
}

public function testPushRaw(): void
public function test_push_raw(): void
{
Queue::pushRaw($payload = Str::random());

Expand All @@ -68,9 +68,9 @@ public function testPushRaw(): void
$this->assertSame(0, Queue::size());
}

public function testPush(): void
public function test_push(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

sleep(1);

Expand All @@ -95,7 +95,7 @@ public function testPush(): void
$this->assertSame(0, Queue::size());
}

public function testPushAfterCommit(): void
public function test_push_after_commit(): void
{
$transaction = new DatabaseTransactionsManager;

Expand All @@ -122,7 +122,7 @@ public function testPushAfterCommit(): void
$this->assertSame(0, Queue::size());
}

public function testLaterRaw(): void
public function test_later_raw(): void
{
$payload = Str::random();
$data = [Str::random() => Str::random()];
Expand Down Expand Up @@ -152,9 +152,9 @@ public function testLaterRaw(): void
$this->assertSame(0, Queue::size());
}

public function testLater(): void
public function test_later(): void
{
Queue::later(3, new TestJob());
Queue::later(3, new TestJob);

sleep(1);

Expand All @@ -179,7 +179,7 @@ public function testLater(): void
$this->assertSame(0, Queue::size());
}

public function testBulk(): void
public function test_bulk(): void
{
$count = 100;
$jobs = [];
Expand All @@ -195,9 +195,9 @@ public function testBulk(): void
$this->assertSame($count, Queue::size());
}

public function testPushEncrypted(): void
public function test_push_encrypted(): void
{
Queue::push(new TestEncryptedJob());
Queue::push(new TestEncryptedJob);

sleep(1);

Expand All @@ -222,7 +222,7 @@ public function testPushEncrypted(): void
$this->assertSame(0, Queue::size());
}

public function testPushEncryptedAfterCommit(): void
public function test_push_encrypted_after_commit(): void
{
$transaction = new DatabaseTransactionsManager;

Expand All @@ -249,9 +249,9 @@ public function testPushEncryptedAfterCommit(): void
$this->assertSame(0, Queue::size());
}

public function testEncryptedLater(): void
public function test_encrypted_later(): void
{
Queue::later(3, new TestEncryptedJob());
Queue::later(3, new TestEncryptedJob);

sleep(1);

Expand All @@ -276,7 +276,7 @@ public function testEncryptedLater(): void
$this->assertSame(0, Queue::size());
}

public function testEncryptedBulk(): void
public function test_encrypted_bulk(): void
{
$count = 100;
$jobs = [];
Expand All @@ -292,7 +292,7 @@ public function testEncryptedBulk(): void
$this->assertSame($count, Queue::size());
}

public function testReleaseRaw(): void
public function test_release_raw(): void
{
Queue::pushRaw($payload = Str::random());

Expand All @@ -318,9 +318,9 @@ public function testReleaseRaw(): void
$this->assertSame(0, Queue::size());
}

public function testRelease(): void
public function test_release(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

sleep(1);

Expand All @@ -344,7 +344,7 @@ public function testRelease(): void
$this->assertSame(0, Queue::size());
}

public function testReleaseWithDelayRaw(): void
public function test_release_with_delay_raw(): void
{
Queue::pushRaw($payload = Str::random());

Expand Down Expand Up @@ -375,9 +375,9 @@ public function testReleaseWithDelayRaw(): void
$this->assertSame(0, Queue::size());
}

public function testReleaseInThePast(): void
public function test_release_in_the_past(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

$job = Queue::pop();
$job->release(-3);
Expand All @@ -390,9 +390,9 @@ public function testReleaseInThePast(): void
$this->assertSame(0, Queue::size());
}

public function testReleaseAndReleaseWithDelayAttempts(): void
public function test_release_and_release_with_delay_attempts(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

sleep(1);

Expand All @@ -417,9 +417,9 @@ public function testReleaseAndReleaseWithDelayAttempts(): void
$this->assertSame(0, Queue::size());
}

public function testDelete(): void
public function test_delete(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

$job = Queue::pop();

Expand All @@ -431,9 +431,9 @@ public function testDelete(): void
$this->assertNull(Queue::pop());
}

public function testFailed(): void
public function test_failed(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

$job = Queue::pop();

Expand Down
Loading
Loading