fix: 优化流量消费队列,防止记录长时间被锁住

This commit is contained in:
xboard
2023-12-04 23:16:18 +08:00
parent 66ab4a4a8e
commit 64cc2d79da
2 changed files with 24 additions and 29 deletions

View File

@@ -170,9 +170,13 @@ class UserService
public function trafficFetch(array $server, string $protocol, array $data, string $nodeIp = null)
{
// 获取子节点
$childServer = ($server['parent_id'] == null && !blank($nodeIp))
? (new ServerService())->getChildServer($server['id'], $protocol, $nodeIp)
: null;
$timestamp = strtotime(date('Y-m-d'));
collect($data)->chunk(1000)->each(function($chunk) use ($timestamp,$server,$protocol, $nodeIp){
TrafficFetchJob::dispatch($server, $chunk->toArray(), $protocol, $timestamp, $nodeIp);
collect($data)->chunk(1000)->each(function($chunk) use ($timestamp,$server,$protocol, $childServer){
TrafficFetchJob::dispatch($server, $chunk->toArray(), $protocol, $timestamp, $childServer);
});
}
}