diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Net/Riak/Role/REST.pm | 43 | ||||
-rw-r--r-- | lib/Net/Riak/Role/UserAgent.pm | 53 |
2 files changed, 21 insertions, 75 deletions
diff --git a/lib/Net/Riak/Role/REST.pm b/lib/Net/Riak/Role/REST.pm index dc8222a..11e6e0e 100644 --- a/lib/Net/Riak/Role/REST.pm +++ b/lib/Net/Riak/Role/REST.pm @@ -1,7 +1,4 @@ package Net::Riak::Role::REST; -{ - $Net::Riak::Role::REST::VERSION = '0.1600'; -} # ABSTRACT: role for REST operations @@ -11,9 +8,8 @@ use Moose::Role; use MooseX::Types::Moose 'Bool'; use Net::Riak::Types qw/HTTPResponse HTTPRequest/; use Data::Dump 'pp'; -use Data::Dumper; -with qw/Net::Riak::Role::REST::Bucket - Net::Riak::Role::REST::Object +with qw/Net::Riak::Role::REST::Bucket + Net::Riak::Role::REST::Object Net::Riak::Role::REST::Link Net::Riak::Role::REST::MapReduce Net::Riak::Role::REST::Search @@ -41,8 +37,8 @@ has disable_return_body => ( has ssl => ( is => 'rw', - isa => Bool, - default => 0 + isa => Bool, + default => 0 ); sub _build_path { @@ -72,9 +68,9 @@ sub send_request { my ($self, $req) = @_; $self->http_request($req); - + my $r = $self->useragent->request($req); - + $self->http_response($r); if ($ENV{RIAK_VERBOSE}) { @@ -95,7 +91,7 @@ sub all_buckets { my $self = shift; my $request = $self->new_request('GET', [$self->prefix], {buckets => 'true'}); my $response = $self->send_request($request); - die "Failed to fetch buckets.. are you running riak 0.14+?" + die "Failed to fetch buckets.. are you running riak 0.14+?" unless $response->is_success; my $resp = JSON::decode_json($response->content); return ref ($resp->{buckets}) eq 'ARRAY' ? @{$resp->{buckets}} : (); @@ -111,28 +107,3 @@ sub stats { } 1; - -__END__ -=pod - -=head1 NAME - -Net::Riak::Role::REST - role for REST operations - -=head1 VERSION - -version 0.1600 - -=head1 AUTHOR - -franck cuny <franck@lumberjaph.net>, robin edwards <robin.ge@gmail.com> - -=head1 COPYRIGHT AND LICENSE - -This software is copyright (c) 2011 by linkfluence. - -This is free software; you can redistribute it and/or modify it under -the same terms as the Perl 5 programming language system itself. - -=cut - diff --git a/lib/Net/Riak/Role/UserAgent.pm b/lib/Net/Riak/Role/UserAgent.pm index c736f0a..63808eb 100644 --- a/lib/Net/Riak/Role/UserAgent.pm +++ b/lib/Net/Riak/Role/UserAgent.pm @@ -23,7 +23,7 @@ has ua_timeout => ( has ssl_opts => ( is => 'rw', - isa => 'HashRef' + isa => 'HashRef' ); has useragent => ( @@ -38,19 +38,19 @@ has useragent => ( my %opts = @LWP::Protocol::http::EXTRA_SOCK_OPTS; $opts{MaxLineLength} = 65_536; @LWP::Protocol::http::EXTRA_SOCK_OPTS = %opts; - my $ua = undef; - - if ( !$self->ssl ) { - $ua = LWP::UserAgent->new( - timeout => $self->ua_timeout, - keep_alive => 1, - ); - } else { - $ua = LWP::UserAgent->new( - timeout => $self->ua_timeout, - keep_alive => 1, - ssl_opts => $self->ssl_opts - ); + my $ua = undef; + + if ( !$self->ssl ) { + $ua = LWP::UserAgent->new( + timeout => $self->ua_timeout, + keep_alive => 1, + ); + } else { + $ua = LWP::UserAgent->new( + timeout => $self->ua_timeout, + keep_alive => 1, + ssl_opts => $self->ssl_opts + ); } $ua->conn_cache(__PACKAGE__->connection_cache); @@ -60,28 +60,3 @@ has useragent => ( ); 1; - -__END__ -=pod - -=head1 NAME - -Net::Riak::Role::UserAgent - useragent for Net::Riak - -=head1 VERSION - -version 0.1600 - -=head1 AUTHOR - -franck cuny <franck@lumberjaph.net>, robin edwards <robin.ge@gmail.com> - -=head1 COPYRIGHT AND LICENSE - -This software is copyright (c) 2011 by linkfluence. - -This is free software; you can redistribute it and/or modify it under -the same terms as the Perl 5 programming language system itself. - -=cut - |