@@ 14-33 (lines=20) @@ | ||
11 | ||
12 | class HTTPChecker extends Checker |
|
13 | { |
|
14 | public function check(MonitorCollection $monitors) |
|
15 | { |
|
16 | $monitors->resetItemKeys(); |
|
17 | $this->monitors = $monitors; |
|
18 | (new EachPromise($this->getPromises($monitors), [ |
|
19 | 'concurrency' => config('laravel-uptime-monitor.uptime_check.concurrent_checks'), |
|
20 | 'fulfilled' => function (ResponseInterface $response, $index) { |
|
21 | $monitor = $this->monitors->getMonitorAtIndex($index); |
|
22 | ||
23 | ConsoleOutput::info("Could reach {$monitor->url}"); |
|
24 | ||
25 | $monitor->uptimeRequestSucceeded($response); |
|
26 | }, |
|
27 | 'rejected' => function (RequestException $exception, $index) { |
|
28 | $monitor = $this->monitors->getMonitorAtIndex($index); |
|
29 | ConsoleOutput::error("Could not reach {$monitor->url} error: `{$exception->getMessage()}`"); |
|
30 | $monitor->uptimeRequestFailed($exception->getMessage()); |
|
31 | }, |
|
32 | ]))->promise()->wait(); |
|
33 | } |
|
34 | ||
35 | protected function getPromises(MonitorCollection $monitors): \Generator |
|
36 | { |
@@ 16-33 (lines=18) @@ | ||
13 | /** |
|
14 | * {@inheritdoc} |
|
15 | */ |
|
16 | public function check(MonitorCollection $monitors) |
|
17 | { |
|
18 | $monitors->resetItemKeys(); |
|
19 | $this->monitors = $monitors; |
|
20 | (new EachPromise($this->getPromises($monitors), [ |
|
21 | 'concurrency' => config('laravel-uptime-monitor.uptime_check.concurrent_checks'), |
|
22 | 'fulfilled' => function ($monitor, $index) { |
|
23 | $monitor = $this->monitors->getMonitorAtIndex($index); |
|
24 | ConsoleOutput::info("Could reach {$monitor->url}"); |
|
25 | $monitor->uptimeRequestSucceeded(new Response(200, [], "Could reach {$monitor->url}")); |
|
26 | }, |
|
27 | 'rejected' => function ($exception, $index) { |
|
28 | $monitor = $this->monitors->getMonitorAtIndex($index); |
|
29 | ConsoleOutput::error("Could not reach {$monitor->url} error: `{$exception->getMessage()}`"); |
|
30 | $monitor->uptimeRequestFailed($exception->getMessage()); |
|
31 | }, |
|
32 | ]))->promise()->wait(); |
|
33 | } |
|
34 | ||
35 | protected function getPromises($monitors): \Generator |
|
36 | { |