Conditions | 3 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
15 | public static function callback(Server $swoole, Process $process) |
||
16 | { |
||
17 | /**@var \Hhxsv5\LaravelS\Components\Prometheus\PrometheusCollector $collector */ |
||
18 | $collector = app(SwooleWorkerCollector::class); |
||
19 | $workerNum = $swoole->setting['worker_num']; |
||
20 | $taskWorkerNum = isset($swoole->setting['task_worker_num']) ? $swoole->setting['task_worker_num'] : 0; |
||
21 | $totalNum = $workerNum + $taskWorkerNum - 1; |
||
22 | $workerIds = range(0, $totalNum); |
||
23 | $runJob = function () use ($swoole, $workerIds, $collector) { |
||
24 | foreach ($workerIds as $workerId) { |
||
25 | $swoole->sendMessage($collector, $workerId); |
||
26 | } |
||
27 | }; |
||
28 | |||
29 | $interval = config('prometheus.collect_metrics_interval', 10) * 1000; |
||
30 | self::$timerId = Timer::tick($interval, $runJob); |
||
31 | } |
||
42 | } |