App-Foca

 view release on metacpan or  search on metacpan

lib/App/Foca/Client.pm  view on Meta::CPAN

    my @results = ();
    my $pm = new Parallel::ForkManager($self->{'maxflight'});
    $pm->run_on_finish(
            sub {
                my ($pid, $exit_code, $id, $exit, $core, $data) = @_;
                
                my $item;
                if ($data->{'got_response'}) {
                    my $response = $data->{'response'};
                    if ($response->is_success) {
                        my $data = $response->decoded_content;
                        chomp($data);
                        $item = {
                            'hostname'  => $id,
                            'ok'        => 1,
                            'output'    => $data};
                        $options->{'on_good'}->($item) if
                            ref $options->{'on_good'} eq 'CODE';
                    } else {
                        my $msg = $response->decoded_content || $response->status_line;
                        chomp($msg);
                        if ($msg eq "500 Can't connect to $id:12346 (connect: timeout)") {
                            $msg = "Connect timeout";
                        }
                        $item = {
                            'hostname'  => $id,
                            'ok'        => 0,
                            'output'    => $msg};
                        $options->{'on_bad'}->($item) if
                            ref $options->{'on_bad'} eq 'CODE';



( run in 0.383 second using v1.01-cache-2.11-cpan-26ccb49234f )