Files
journal/application/api/job/dbpush.php

38 lines
778 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\api\job;
use think\queue\Job;
use app\master\service\DbPushManager;
/**
* 数据库收录推送 - 异步队列任务
* 队列名dbpush
*/
class dbpush
{
public function handle(Job $job, $data)
{
$manager = new DbPushManager();
$ok = $manager->executeAndLog(
$data['log_id'],
$data['stage_id'],
$data['pusher'],
isset($data['options']) ? $data['options'] : []
);
if ($ok) {
$job->delete();
return;
}
// 失败重试
$max = (int) config('dbpush.max_attempt');
if ($job->attempts() >= $max) {
$job->delete();
} else {
$job->release(30); // 30 秒后重试
}
}
}