class PushJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable;
private $data;
/**
* @param $data
*/
public function __construct( $data)
{
$this->data = $data;
}
/**
* @param WechatService $service
*/
public function handle(WechatService $service)
{
$service->sendTemplate($this->data);
}
/**
* 實現 Telescope 標籤定義,生成環境加入以下標籤進行監控
* @return array
*/
public function tags(): array
{
return ['Template:'.$this->data->template_id];
}
}
再生成環境下新增以下tag可以實現除錯
tags()方法會被vendor/laravel/telescope/src/Watchers/JobWatcher.php下recordJob中$this->tags()呼叫,
public function recordJob($connection, $queue, array $payload)
{
if (! Telescope::isRecording()) {
return;
}
$content = array_merge([
'status' => 'pending',
], $this->defaultJobData($connection, $queue, $payload, $this->data($payload)));
Telescope::recordJob(
$entry = IncomingEntry::make($content)
->withFamilyHash($content['data']['batchId'] ?? null)
->tags($this->tags($payload))
);
return $entry;
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結