Skip to content

Commit

Permalink
Move & rename queue monitor handler
Browse files Browse the repository at this point in the history
  • Loading branch information
romanzipp committed Mar 27, 2020
1 parent b62aa5d commit 0edcfbc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/Providers/QueueMonitorProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Queue\QueueManager;
use Illuminate\Support\ServiceProvider;
use romanzipp\QueueMonitor\Models\Monitor;
use romanzipp\QueueMonitor\QueueMonitorHandler;
use romanzipp\QueueMonitor\Services\QueueMonitor;

class QueueMonitorProvider extends ServiceProvider
{
Expand All @@ -22,7 +22,7 @@ public function boot()
{
if ($this->app->runningInConsole()) {

if (QueueMonitorHandler::$loadMigrations) {
if (QueueMonitor::$loadMigrations) {
$this->loadMigrationsFrom(
dirname(__DIR__) . '/../migrations'
);
Expand All @@ -41,19 +41,19 @@ public function boot()
$manager = app(QueueManager::class);

$manager->before(static function (JobProcessing $event) {
QueueMonitorHandler::handleJobProcessing($event);
QueueMonitor::handleJobProcessing($event);
});

$manager->after(static function (JobProcessed $event) {
QueueMonitorHandler::handleJobProcessed($event);
QueueMonitor::handleJobProcessed($event);
});

$manager->failing(static function (JobFailed $event) {
QueueMonitorHandler::handleJobFailed($event);
QueueMonitor::handleJobFailed($event);
});

$manager->exceptionOccurred(static function (JobExceptionOccurred $event) {
QueueMonitorHandler::handleJobExceptionOccurred($event);
QueueMonitor::handleJobExceptionOccurred($event);
});
}

Expand All @@ -69,7 +69,7 @@ public function register()
dirname(__DIR__) . '/../config/queue-monitor.php', 'queue-monitor'
);

QueueMonitorHandler::$model = config('queue-monitor.model') ?: Monitor::class;
QueueMonitor::$model = config('queue-monitor.model') ?: Monitor::class;
}
}
}
4 changes: 2 additions & 2 deletions src/QueueMonitorHandler.php → src/Services/QueueMonitor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace romanzipp\QueueMonitor;
namespace romanzipp\QueueMonitor\Services;

use Illuminate\Contracts\Queue\Job as JobContract;
use Illuminate\Queue\Events\JobExceptionOccurred;
Expand All @@ -11,7 +11,7 @@
use romanzipp\QueueMonitor\Models\Contracts\MonitorContract;
use romanzipp\QueueMonitor\Traits\IsMonitored;

class QueueMonitorHandler
class QueueMonitor
{
private const TIMESTAMP_EXACT_FORMAT = 'Y-m-d H:i:s.u';

Expand Down
6 changes: 3 additions & 3 deletions src/Traits/IsMonitored.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace romanzipp\QueueMonitor\Traits;

use romanzipp\QueueMonitor\Models\Contracts\MonitorContract;
use romanzipp\QueueMonitor\QueueMonitorHandler;
use romanzipp\QueueMonitor\Services\QueueMonitor;

/**
* @mixin \Illuminate\Queue\InteractsWithQueue
Expand Down Expand Up @@ -97,11 +97,11 @@ protected function getQueueMonitor(): ?MonitorContract
return null;
}

if ( ! $jobId = QueueMonitorHandler::getJobId($this->job)) {
if ( ! $jobId = QueueMonitor::getJobId($this->job)) {
return null;
}

$model = QueueMonitorHandler::getModel();
$model = QueueMonitor::getModel();

return $model::whereJob($jobId)
->orderBy('started_at', 'desc')
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
use Illuminate\Queue\QueueManager;
use Orchestra\Testbench\TestCase as BaseTestCase;
use romanzipp\QueueMonitor\Providers\QueueMonitorProvider;
use romanzipp\QueueMonitor\QueueMonitorHandler;
use romanzipp\QueueMonitor\Services\QueueMonitor;

class TestCase extends BaseTestCase
{
use DatabaseMigrations;

public function setUp(): void
{
QueueMonitorHandler::$loadMigrations=true;
QueueMonitor::$loadMigrations=true;

parent::setUp();
}
Expand Down

0 comments on commit 0edcfbc

Please sign in to comment.