Coro-Amazon-SimpleDB

 view release on metacpan or  search on metacpan

lib/Coro/Amazon/SimpleDB.pm  view on Meta::CPAN


sub async_requests {
    my ($self, @requests) = @_;

    my $debug = $self->DEBUG;
    require Time::HiRes and Time::HiRes->import('time') if $debug;
    my ($start, $duration) = (0, 0);
    my @responses = ();
    $self->bug("starting async enqueues");
    $start = time() if $debug;
    for ($[ .. $#requests) {
        my $idx = $_;
        my $request = $requests[$idx];
        $self->bug("adding request $request");
        my $coro = async {
            my ($start, $duration) = (0, 0);
            $self->bug("starting request for $request");
            $start = time() if $debug;
            $responses[$idx] = eval { $self->_process_request($request) };
            # Store the exception instead of the response (which
            # should be undef) if there was a problem.

lib/Coro/Amazon/SimpleDB.pm  view on Meta::CPAN

        my $attributes
            = (ref $response eq 'Amazon::SimpleDB::Model::GetAttributesResponse') ?
                  {
                      map {
                          defined $_->getName ? ($_->getName, $_->getValue) : ()
                      } @{ $response->getGetAttributesResult->getAttribute }
                  }
            :     $response
            ;
        ($item_name => $attributes);
    } $[ .. $#items;
    return \%items;
}



1;

__END__

=head1 NAME

t/02-live.t  view on Meta::CPAN

    } keys %items;
    return @requests;
}


sub expected_response_types {
    my $responses = shift;
    my $expected_types = shift;
    return (@{$responses} && @{$expected_types}) and not first {
        ref $responses->[$_] ne $expected_types->[$_];
    } $[ .. max($#{$responses}, $#{$expected_types});
}


sub expected_response_type {
    my $responses = shift;
    my $expected_type = shift;
    my $count = shift;
    return expected_response_types($responses, [ map { $expected_type } 1 .. $count ]);
}



( run in 0.236 second using v1.01-cache-2.11-cpan-cc502c75498 )