big update all menus
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\NasMikrotik;
|
||||
use App\Services\Nas\MikrotikHealthService;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Throwable;
|
||||
|
||||
class CheckMikrotikConnection implements ShouldBeUnique, ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 1;
|
||||
|
||||
public int $timeout = 25;
|
||||
|
||||
public int $uniqueFor = 240;
|
||||
|
||||
public function __construct(public int $mikrotikId)
|
||||
{
|
||||
$this->onQueue(config('nas.health.queue', 'nas-health'));
|
||||
}
|
||||
|
||||
public function uniqueId(): string
|
||||
{
|
||||
return (string) $this->mikrotikId;
|
||||
}
|
||||
|
||||
public function handle(MikrotikHealthService $health): void
|
||||
{
|
||||
$mikrotik = NasMikrotik::whereKey($this->mikrotikId)->where('status', 'active')->first();
|
||||
if (! $mikrotik) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$health->check($mikrotik);
|
||||
} catch (Throwable) {
|
||||
// Health service has persisted the offline state and next backoff time.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace App\Jobs;
|
||||
use App\Models\CustomerNasAccount;
|
||||
use App\Services\Nas\CustomerAccountReconciliationService;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Throwable;
|
||||
class ReconcileCustomerNasAccount implements ShouldQueue, ShouldBeUnique
|
||||
{
|
||||
use Queueable; public int $tries=1; public int $timeout=30; public int $uniqueFor=240;
|
||||
public function __construct(public int $accountId){$this->onQueue('nas-reconciliation');}
|
||||
public function uniqueId(): string{return (string)$this->accountId;}
|
||||
public function handle(CustomerAccountReconciliationService $service): void { $a=CustomerNasAccount::find($this->accountId); if(!$a)return; try{$service->reconcile($a);}catch(Throwable $e){$a->update(['last_reconciled_at'=>now(),'last_sync_error'=>$e->getMessage()]);} }
|
||||
}
|
||||
Reference in New Issue
Block a user