Amazon-DynamoDB
view release on metacpan or search on metacpan
lib/Amazon/DynamoDB/20120810.pm view on Meta::CPAN
my $complete = sub {
$self->_request($req)->transform(
fail => sub {
my ($status, $resp, $req)= @_;
my $r;
if (defined($resp) && defined($resp->code)) {
if ($resp->code == 500) {
$do_retry = 1;
$current_retry++;
} elsif ($resp->code == 400) {
my $json = $resp->can('decoded_content')
? $resp->decoded_content
: $resp->body; # Mojo
$r = decode_json($json);
if ($r->{__type} =~ /ProvisionedThroughputExceededException$/) {
# Need to sleep
$do_retry = 1;
$current_retry++;
} else {
# extract the type into a better prettyier name.
lib/Amazon/DynamoDB/LWP.pm view on Meta::CPAN
sub new { my $class = shift; bless {@_}, $class }
sub request {
my $self = shift;
my $req = shift;
# print "Sending : " . $req->as_string() . "\n\n";
my $resp = $self->ua->request($req);
# print "Got back: " . $resp->as_string() . "\n\n";
return Future->new->done($resp->decoded_content) if $resp->is_success;
my $status = join ' ', $resp->code, $resp->message;
return Future->new->fail($status, $resp, $req)
}
sub ua { shift->{ua} ||= LWP::UserAgent->new(keep_alive => 10,
agent => 'Amazon::DynamoDB/1.0',
timeout => 90,
); }
lib/Amazon/DynamoDB/LWP.pm view on Meta::CPAN
requests and return a L<Future> containing the result. Used internally by
L<Amazon::DynamoDB>.
=head2 new
Instantiate.
=head2 request
Issues the request. Expects a single L<HTTP::Request> object,
and returns a L<Future> which will resolve to the decoded
response content on success, or the failure reason on failure.
=head2 ua
Returns the L<LWP::UserAgent> instance.
=head2 delay
Waits for a given interval of seconds.
lib/Amazon/DynamoDB/MojoUA.pm view on Meta::CPAN
requests and return a L<Future> containing the result. Used internally by
L<Amazon::DynamoDB>.
=head2 new
Instantiate.
=head2 request
Issues the request. Expects a single L<HTTP::Request> object,
and returns a L<Future> which will resolve to the decoded
response content on success, or the failure reason on failure.
=head2 ua
Returns the L<LWP::UserAgent> instance.
=head1 NAME
Amazon::DynamoDB::MojoUA - make requests using L<Mojo::UserAgent>
lib/Amazon/DynamoDB/NaHTTP.pm view on Meta::CPAN
$self->ua->do_request(
request => $req,
host => $host,
port => $port || 80,
on_response => sub {
$resp = shift;
}
)-> transform(
done => sub {
if ($resp->is_success()) {
return $resp->decoded_content;
} else {
my $status = join ' ', $resp->code, $resp->message;
return Future->new->fail($status, $resp, $req)
}
},
fail => sub {
my $status = join ' ', $resp->code, $resp->message;
return ($status, $resp, $req);
},
);
lib/Amazon/DynamoDB/NaHTTP.pm view on Meta::CPAN
requests and return a L<Future> containing the result. Used internally by
L<Amazon::DynamoDB>.
=head2 new
Instantiate.
=head2 request
Issues the request. Expects a single L<HTTP::Request> object,
and returns a L<Future> which will resolve to the decoded
response content on success, or the failure reason on failure.
=head2 ua
Returns a L<Net::Async::HTTP> instance.
=head1 NAME
Amazon::DynamoDB::NaHTTP - make requests using L<Net::Async::HTTP>
( run in 0.506 second using v1.01-cache-2.11-cpan-26ccb49234f )