summaryrefslogtreecommitdiff
path: root/lib/Net/Riak/Client.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Net/Riak/Client.pm')
-rw-r--r--lib/Net/Riak/Client.pm32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/Net/Riak/Client.pm b/lib/Net/Riak/Client.pm
index 19d172f..e76a0ef 100644
--- a/lib/Net/Riak/Client.pm
+++ b/lib/Net/Riak/Client.pm
@@ -2,12 +2,10 @@ package Net::Riak::Client;
use Moose;
use MIME::Base64;
+use Moose::Util::TypeConstraints;
-with qw/
- Net::Riak::Role::REST
- Net::Riak::Role::UserAgent
- Net::Riak::Role::Hosts
- /;
+class_type 'HTTP::Request';
+class_type 'HTTP::Response';
has prefix => (
is => 'rw',
@@ -29,6 +27,24 @@ has client_id => (
isa => 'Str',
lazy_build => 1,
);
+has http_request => (
+ is => 'rw',
+ isa => 'HTTP::Request',
+);
+
+has http_response => (
+ is => 'rw',
+ isa => 'HTTP::Response',
+ handles => ['is_success']
+);
+
+with 'Net::Riak::Role::UserAgent';
+with qw/
+ Net::Riak::Role::REST
+ Net::Riak::Role::Hosts
+ /;
+
+
sub _build_client_id {
"perl_net_riak" . encode_base64(int(rand(10737411824)), '');
@@ -36,9 +52,9 @@ sub _build_client_id {
sub is_alive {
my $self = shift;
- my $request = $self->request('GET', ['ping']);
- my $response = $self->useragent->request($request);
- $response->is_success ? return 1 : return 0;
+ my $request = $self->new_request('GET', ['ping']);
+ my $response = $self->send_request($request);
+ $self->is_success ? return 1 : return 0;
}
1;