Amazon-DynamoDB

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Amazon-DynamoDB
requires:
  AWS::Signature4: '0'
  B: '0'
  Future: '0'
  Future::Utils: '0'
  HTTP::Request: '0'
  IO::Async::Timer::Countdown: '0'
  JSON::MaybeXS: '0'
  Kavorka: '0'
  LWP::UserAgent: '0'
  List::MoreUtils: '0'
  List::Util: '0'
  MIME::Base64: '0'
  Module::Load: '0'
  Mojo::UserAgent: '0'
  Net::Async::HTTP: '0.30'

Makefile.PL  view on Meta::CPAN

  },
  "DISTNAME" => "Amazon-DynamoDB",
  "EXE_FILES" => [],
  "LICENSE" => "perl",
  "NAME" => "Amazon::DynamoDB",
  "PREREQ_PM" => {
    "AWS::Signature4" => 0,
    "B" => 0,
    "Future" => 0,
    "Future::Utils" => 0,
    "HTTP::Request" => 0,
    "IO::Async::Timer::Countdown" => 0,
    "JSON::MaybeXS" => 0,
    "Kavorka" => 0,
    "LWP::UserAgent" => 0,
    "List::MoreUtils" => 0,
    "List::Util" => 0,
    "MIME::Base64" => 0,
    "Module::Load" => 0,
    "Mojo::UserAgent" => 0,
    "Net::Async::HTTP" => "0.30",

Makefile.PL  view on Meta::CPAN

);


my %FallbackPrereqs = (
  "AWS::Signature4" => 0,
  "B" => 0,
  "Data::Dumper" => 0,
  "ExtUtils::MakeMaker" => 0,
  "Future" => 0,
  "Future::Utils" => 0,
  "HTTP::Request" => 0,
  "IO::Async::Loop" => 0,
  "IO::Async::SSL" => 0,
  "IO::Async::Timer::Countdown" => 0,
  "JSON::MaybeXS" => 0,
  "Kavorka" => 0,
  "LWP::UserAgent" => 0,
  "List::MoreUtils" => 0,
  "List::Util" => 0,
  "MIME::Base64" => 0,
  "Module::Load" => 0,

lib/Amazon/DynamoDB/20120810.pm  view on Meta::CPAN



use Future;
use Future::Utils qw(repeat try_repeat);
use POSIX qw(strftime);
use JSON::MaybeXS qw(decode_json encode_json);
use MIME::Base64;
use List::Util;
use List::MoreUtils;
use B qw(svref_2object);
use HTTP::Request;
use Kavorka;
use Amazon::DynamoDB::Types;
use Type::Registry;
use VM::EC2::Security::CredentialCache;
use AWS::Signature4;
   
BEGIN {
    my $reg = "Type::Registry"->for_me; 
    $reg->add_types(-Standard);
    $reg->add_types("Amazon::DynamoDB::Types");

lib/Amazon/DynamoDB/20120810.pm  view on Meta::CPAN


    $self->_scan_or_query_process('Scan', $payload, $code, { ResultLimit => $Limit});
}


method make_request(Str :$target,
                    HashRef :$payload,
                ) {
    my $api_version = '20120810';
    my $host = $self->host;
    my $req = HTTP::Request->new(
        POST => (($self->ssl) ? 'https' : 'http') . '://' . $self->host . ($self->port ? (':' . $self->port) : '') . '/'
    );
    $req->header( host => $host );
    # Amazon requires ISO-8601 basic format
    my $now = time;
    my $http_date = strftime('%Y%m%dT%H%M%SZ', gmtime($now));
    my $date = strftime('%Y%m%d', gmtime($now));

    $req->protocol('HTTP/1.1');
    $req->header( 'Date' => $http_date );

lib/Amazon/DynamoDB/20120810.pm  view on Meta::CPAN

        $req->header('x-amz-security-token' => $creds->sessionToken);
    }        

    my $signer = AWS::Signature4->new(-access_key => $self->access_key,
                                      -secret_key => $self->secret_key);
    
    $signer->sign($req);
    return $req;
}

method _request(HTTP::Request $req) {
    $self->implementation->request($req);
}


# Since scan and query have the same type of responses share the processing.
method _scan_or_query_process (Str $target,
                               HashRef $payload,
                               CodeRef $code,
                               HashRef $args) {
    my $finished = 0;

lib/Amazon/DynamoDB/20120810.pm  view on Meta::CPAN

fun _decode_item_attributes(Maybe[HashRef] $item) {
    my $r;
    foreach my $key (keys %$item) {
        my $type = (keys %{$item->{$key}})[0];
        my $value = $item->{$key}->{$type};
        $r->{$key} = _decode_type_and_value($type, $item->{$key}->{$type});
    }
    return $r;
}

method _process_request(HTTP::Request $req, CodeRef $done?) {
    my $current_retry = 0;
    my $do_retry = 1;
    try_repeat {
        $do_retry = 0;
        
        my $sleep_amount = 0;
        if ($current_retry > 0) {
            $sleep_amount = (2 ** $current_retry * 50)/1000;
        }

lib/Amazon/DynamoDB/20120810.pm  view on Meta::CPAN


Amazon::DynamoDB::20120810 - interact with DynamoDB using API version 20120810

=head1 METHODS - Internal 

The following methods are intended for internal use and are documented
purely for completeness - for normal operations see L</METHODS> instead.

=head2 make_request

Generates an L<HTTP::Request>.

=head1 FUNCTIONS - Internal

=head2 _encode_type_and_value

Returns an appropriate type (N, S, SS etc.) and stringified/encoded value for the given
value.

DynamoDB only uses strings even if there is a Numeric value specified,
so while the type will be expressed as a Number the value will be

lib/Amazon/DynamoDB/LWP.pm  view on Meta::CPAN

Provides a L</request> method which will use L<LWP::UserAgent> to make
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

Provides a L</request> method which will use L<LWP::UserAgent> to make
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

Provides a L</request> method which will use L<Net::Async::HTTP> to make
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.717 second using v1.01-cache-2.11-cpan-de7293f3b23 )