diff options
author | franck cuny <franck@lumberjaph.net> | 2010-06-14 15:19:24 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-06-14 15:19:24 +0200 |
commit | c12c630eb26e73612df5dba7e796cfe5bee4309d (patch) | |
tree | b61a60febc9b332784963ed67ec307e42dbea3d4 /lib | |
parent | add handles for has_siblings and hs_no_siblings (diff) | |
download | net-riak-c12c630eb26e73612df5dba7e796cfe5bee4309d.tar.gz |
code for client move to N::R::Client
Diffstat (limited to '')
-rw-r--r-- | lib/Net/Riak.pm | 65 |
1 files changed, 17 insertions, 48 deletions
diff --git a/lib/Net/Riak.pm b/lib/Net/Riak.pm index dda2ccc..bd76cce 100644 --- a/lib/Net/Riak.pm +++ b/lib/Net/Riak.pm @@ -3,32 +3,29 @@ package Net::Riak; # ABSTRACT: Interface to Riak use Moose; -use MIME::Base64; +use Net::Riak::Client; use Net::Riak::Bucket; -use Net::Riak::MapReduce; - -with qw/ - Net::Riak::Role::REST - Net::Riak::Role::UserAgent - /; - -has host => - (is => 'rw', isa => 'Str', coerce => 1, default => 'http://127.0.0.1:8098'); -has prefix => (is => 'rw', isa => 'Str', default => 'riak'); -has mapred_prefix => (is => 'rw', isa => 'Str', default => 'mapred'); -has r => (is => 'rw', isa => 'Int', default => 2); -has w => (is => 'rw', isa => 'Int', default => 2); -has dw => (is => 'rw', isa => 'Int', default => 2); -has client_id => (is => 'rw', isa => 'Str', lazy_build => 1,); - -sub _build_client_id { - "perl_net_riak" . encode_base64(int(rand(10737411824)), ''); + +with 'Net::Riak::Role::MapReduce'; + +has client => ( + is => 'rw', + isa => 'Net::Riak::Client', + required => 1, + handles => [qw/request useragent/] +); + +sub BUILDARGS { + my ($class, %args) = @_; + my $client = Net::Riak::Client->new(%args); + $args{client} = $client; + \%args; } sub bucket { my ($self, $name) = @_; - my $bucket = Net::Riak::Bucket->new(name => $name, client => $self); + my $bucket = Net::Riak::Bucket->new(name => $name, client => $self->client); $bucket; } @@ -39,34 +36,6 @@ sub is_alive { $response->is_success ? return 1 : return 0; } -sub add { - my ($self, @args) = @_; - my $mr = Net::Riak::MapReduce->new(client => $self); - $mr->add(@args); - $mr; -} - -sub link { - my ($self, @args) = @_; - my $mr = Net::Riak::MapReduce->new(client => $self); - $mr->link(@args); - $mr; -} - -sub map { - my ($self, @args) = @_; - my $mr = Net::Riak::MapReduce->new(client => $self); - $mr->mapd(@args); - $mr; -} - -sub reduce { - my ($self, @args) = @_; - my $mr = Net::Riak::MapReduce->new(client => $self); - $mr->reduce(@args); - $mr; -} - 1; =head1 SYNOPSIS |