<commit_before><?php
namespace Lezhnev74\HLSMonitor\Services\UrlGatherer;


use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Promise\EachPromise;
use Psr\Http\Message\ResponseInterface;

class GuzzleCurlChecker implements GathersUrls
{
    private $client;
    private $concurrency;
    
    public function __construct(Client $client, int $concurrency = 25)
    {
        $this->client      = $client;
        $this->concurrency = $concurrency;
    }
    
    
    function gatherWithoutBody(
        array $urls,
        callable $on_fail_url,
        callable $on_good_url = null
    ) {
        $promises = (function () use ($urls, $on_fail_url, $on_good_url) {
            foreach ($urls as $url) {
                yield $this->client->requestAsync('HEAD', $url, [
                    'connect_timeout' => 10,
                    'timeout'         => 10,
                ])->then(
                    function (ResponseInterface $res) use ($url, $on_good_url) {
                        // on good
                        $on_good_url($url, "");
                    },
                    function (RequestException $e) use ($url, $on_fail_url) {
                        // on bad
                        $on_fail_url($url, $e->getMessage());
                    }
                );
            }
        })();
        
        (new EachPromise($promises, [<commit_msg>change timeout to 30 sec<commit_after><?php
namespace Lezhnev74\HLSMonitor\Services\UrlGatherer;


use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Promise\EachPromise;
use Psr\Http\Message\ResponseInterface;

class GuzzleCurlChecker implements GathersUrls
{
    private $client;
    private $concurrency;
    
    public function __construct(Client $client, int $concurrency = 25)
    {
        $this->client      = $client;
        $this->concurrency = $concurrency;
    }
    
    
    function gatherWithoutBody(
        array $urls,
        callable $on_fail_url,
        callable $on_good_url = null
    ) {
        $promises = (function () use ($urls, $on_fail_url, $on_good_url) {
            foreach ($urls as $url) {
                yield $this->client->requestAsync('HEAD', $url, [
                    'connect_timeout' => 10,
                    'timeout'         => 30,
                ])->then(
                    function (ResponseInterface $res) use ($url, $on_good_url) {
                        // on good
                        $on_good_url($url, "");
                    },
                    function (RequestException $e) use ($url, $on_fail_url) {
                        // on bad
                        $on_fail_url($url, $e->getMessage());
                    }
                );
            }
        })();
        
        (new EachPromise($promises, [
{'fraction_non_alphanumeric': 0.1112291888062345, 'fraction_numerical': 0.006376195536663124, 'mean_word_length': 1.5789954337899543, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4883932', 'n_tokens_mistral': 817, 'n_tokens_neox': 787, 'n_words': 160}