feat: quene
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\WalletAddress;
|
||||
use App\Services\AutoTransferService;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class AutoTransferAddress implements ShouldQueue, ShouldBeUnique
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 1;
|
||||
|
||||
public int $timeout = 180;
|
||||
|
||||
public int $uniqueFor = 180;
|
||||
|
||||
public function __construct(
|
||||
public int $walletAddressId,
|
||||
public string $reason = 'cron',
|
||||
) {}
|
||||
|
||||
public function uniqueId(): string
|
||||
{
|
||||
return 'auto-transfer:'.$this->walletAddressId;
|
||||
}
|
||||
|
||||
public function handle(AutoTransferService $autoTransfer): void
|
||||
{
|
||||
$address = WalletAddress::query()->find($this->walletAddressId);
|
||||
if ($address === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$autoTransfer->evaluate($address, $this->reason);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\PhotoArchiveIngest;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class ExtractPhotoArchive implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 1;
|
||||
|
||||
public int $timeout = 180;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $photoMeta
|
||||
* @param array<string, mixed> $rawCounters
|
||||
*/
|
||||
public function __construct(
|
||||
public int $deviceId,
|
||||
public string $inboxPath,
|
||||
public string $batchBase,
|
||||
public array $photoMeta,
|
||||
public string $flavor,
|
||||
public array $rawCounters,
|
||||
) {}
|
||||
|
||||
public function handle(PhotoArchiveIngest $ingest): void
|
||||
{
|
||||
$ingest->process(
|
||||
$this->deviceId,
|
||||
$this->inboxPath,
|
||||
$this->batchBase,
|
||||
$this->photoMeta,
|
||||
$this->flavor,
|
||||
$this->rawCounters,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\PageVisit;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class RecordPageHit implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $attrs
|
||||
*/
|
||||
public function __construct(
|
||||
public array $attrs,
|
||||
public int $chain,
|
||||
) {}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
PageVisit::recordLanding($this->attrs, $this->chain);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\TelegramNotifier;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class SendTelegramMessage implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
public int $timeout = 20;
|
||||
|
||||
public function __construct(
|
||||
public string $chatId,
|
||||
public string $text,
|
||||
public ?string $token = null,
|
||||
) {}
|
||||
|
||||
public function handle(TelegramNotifier $telegram): void
|
||||
{
|
||||
$telegram->sendToChat($this->chatId, $this->text, $this->token);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user