Voldemort.pm

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 19 / 19 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Voldemort/ProtoBuff/PutMessage.pm ↑ Summary Voldemort/Message.pm »
1 package Voldemort;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $VERSION = '0.11';
8 1 @ISA = qw(Exporter);
9 1 @EXPORT = qw();
10 1 @EXPORT_OK = qw();
11 1 %EXPORT_TAGS = ();
12 }
13  
14  
15  
16 =head1 NAME
17  
18 Voldemort - A voldemort client and infrastructure
19  
20 =head1 SYNOPSIS
21  
22 Voldemort::Store is a basic client to get, delete and put data. The goal is not to be a complete POE enabled, client-side load-balancing client but a simpler sync/async client that communicates with a server. The desire is this client can be embeded in larger structures, or not.
23  
24 An admin client should be coming soon.
25  
26 =head1 DESCRIPTION
27  
28 This distribution includes a few classes, the primary are:
29  
30 =head2 Voldemort::Store
31  
32 A top level API for communicating with a Voldemort::Connection
33  
34 =head2 Voldemort::Connection
35  
36 An interface for the store to communicate to a server using sync/async methods.
37  
38 =head2 Voldemort::Message
39  
40 An interface for message marshalling/unmarshalling messages. When a store sends a message, in asyncronous mode it will store a reference to the implemented message to unmarshall the next message.
41  
42 =head2 Voldemort::Protobuff::Connection
43  
44 An implementation of Voldemort::Connection using Protocol Buffers.
45  
46 =head2 Voldemort::ProtoBuff::GetMessage
47  
48 =head2 Voldemort::ProtoBuff::DeleteMessage
49  
50 =head2 Voldemort::ProtoBuff::PutMessage
51  
52 =head2 Voldemort::ProtoBuff::Spec2
53  
54 Implementations of the various marshalling/unmarshalling from Protocol Buffer byte data to real data. Spec2 is a generated module for protocol buffers that is used by Get/Delete/PutMessage. They are automatically created and set when Voldemort::Connection::Protobuff is instanciated, by default.
55  
56 =head2 Voldemort::ProtoBuff::Resolver
57  
58 =head2 Voldemort::ProtoBuff::DefaultResolver
59  
60 An interface for dealing with multiple vectors (versions) in voldemort for a given key. If vector clocks are not used, it is entirely possible to ignore this class. The implementation, DefaultResolver is defaulted when Voldemort::ProtoBuff::GetMessage is instanciated. If two vectors exist for a given piece of data, the resolver will carp. If vector clocks are not used, where all node ids are defaulting to 0, the default implementation will be fine, otherwise implement your own strategy.
61  
62 Implementing your own resolver entails handling an array of Voldemort::ProtoBuff::Spec2::Versioned objects. Each element in the array represents a vector owned by an entity (or group of entites, which is a composite entity) and a value. In the USAGE section is an example that takes multiple vectors and merges the result.
63  
64 =head1 USAGE
65  
66 =head2 Quick start, no vector clocks
67  
68 use strict;
69 use Moose;
70  
71 use Voldemort::Store;
72 use Voldemort::ProtoBuff::Connection;
73  
74 my $connection = Voldemort::ProtoBuff::Connection->new(
75 'to' => 'localhost:6666'
76 );
77  
78 my $store = new Voldemort::Store( connection => $connection );
79 $store->default_store('test');
80 $x->put( key=>1, value=>'5' );
81 print $x->get( key=>1 );
82  
83 =head2 Quick start, vector clocks
84  
85 use strict;
86 use warnings;
87 use Voldemort::Store;
88 use Voldemort::ProtoBuff::Connection;
89  
90 my $connection = Voldemort::ProtoBuff::Connection->new(
91 'to' => 'localhost:6666',
92 'get_handler' =>
93 Voldemort::ProtoBuff::GetMessage->new(
94 'resolver' => Foo->new() )
95 );
96  
97 my $store = Voldemort::Store->new( connection => $connection );
98  
99 $store->default_store('test');
100  
101 ####
102 package Foo;
103  
104 use Moose;
105 use Voldemort::ProtoBuff::Resolver;
106  
107 with 'Voldemort::Protobuff::Resolver';
108  
109 sub resolve
110 {
111 shift;
112 my $versions = shift;
113 my $size = (defined $versions) ? scalar @{$versions} : 0;
114 if( $size == 0 )
115 {
116 return (undef, []);
117 }
118 elsif( $size == 1 )
119 {
120 return $$versions[0]->value, [];
121 }
122  
123 # pool everyone's likes
124 my %result = ();
125 my %nodes = ();
126 my @nodeRecords = ();
127 foreach my $record (@{$versions})
128 {
129 map { $result{$_} = $_ }
130 split(/,/, $record->value);
131 map { $nodes{ $_->node_id } = 1 }
132 @{$record->version->entries};
133 push @nodeRecords,
134 [map {$_->node_id} @{$record->version->entries}];
135 }
136 return (join ",", keys %result), \@nodeRecords;
137 }
138  
139 =head1 BUGS
140  
141 Zer are no more bugs! (for the moment)
142  
143 =head1 SUPPORT
144  
145 exussum@gmail.com
146  
147 =head1 AUTHOR
148  
149 Spencer Portee
150 CPAN ID: EXUSSUM
151 exussum@gmail.com
152  
153 =head1 SOURCE
154  
155 http://bitbucket.org/exussum/pockito/
156  
157 =head1 COPYRIGHT
158  
159 This program is free software licensed under the...
160  
161 The BSD License
162  
163 The full text of the license can be found in the
164 LICENSE file included with this module.
165  
166  
167 =head1 SEE ALSO
168  
169 perl(1).
170  
171 =cut
172  
173 1 1;
« Voldemort/ProtoBuff/PutMessage.pm ↑ Summary Voldemort/Message.pm »