riakpb 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/riak/client/rpc.rb +13 -8
- data/lib/riak/util/decode.rb +17 -4
- data/lib/riak.rb +1 -1
- data/load_stocks.rb +0 -0
- data/riakpb.gemspec +3 -3
- metadata +4 -4
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require './lib/riak'
|
|
6
6
|
gemspec = Gem::Specification.new do |gem|
|
7
7
|
gem.name = "riakpb"
|
8
8
|
gem.summary = %Q{riakpb is a protocol buffer client for Riak--the distributed database by Basho.}
|
9
|
-
gem.description = %Q{riakpb is a protocol buffer client for Riak--the distributed database by Basho.
|
9
|
+
gem.description = %Q{riakpb is a protocol buffer client for Riak--the distributed database by Basho.}
|
10
10
|
gem.version = Riak::VERSION
|
11
11
|
gem.email = "me@inherentlylame.com"
|
12
12
|
gem.homepage = "http://github.com/aitrus/riak-pbclient"
|
data/lib/riak/client/rpc.rb
CHANGED
@@ -14,7 +14,7 @@ module Riak
|
|
14
14
|
include Riak::Util::Encode
|
15
15
|
include Riak::Util::Decode
|
16
16
|
|
17
|
-
RECV_LIMIT=
|
17
|
+
RECV_LIMIT=1073741824
|
18
18
|
|
19
19
|
attr_reader :req_message, :response, :resp_message_codes, :resp_message, :status
|
20
20
|
|
@@ -30,7 +30,7 @@ module Riak
|
|
30
30
|
|
31
31
|
# Request / Response Data
|
32
32
|
@resp_message_codes = -1
|
33
|
-
@resp_message =
|
33
|
+
@resp_message = []
|
34
34
|
@req_message_code = -1
|
35
35
|
@req_message = ''
|
36
36
|
@response = ''
|
@@ -39,11 +39,12 @@ module Riak
|
|
39
39
|
# Clears the request / response data, in preparation for a new request
|
40
40
|
def clear
|
41
41
|
@resp_message_codes = -1
|
42
|
-
@resp_message =
|
42
|
+
@resp_message = []
|
43
43
|
@req_message_code = -1
|
44
44
|
@req_message = ''
|
45
45
|
@response = ''
|
46
46
|
@status = false
|
47
|
+
@buffer = ''
|
47
48
|
end
|
48
49
|
|
49
50
|
# Opens a TCPSocket connection with the riak host/node
|
@@ -93,9 +94,9 @@ module Riak
|
|
93
94
|
end
|
94
95
|
|
95
96
|
socket.send(@req_message, 0)
|
96
|
-
self.
|
97
|
+
self.parse_response socket.recv(@limit)
|
97
98
|
|
98
|
-
end while(false == (@response
|
99
|
+
end while(false == (@response[:done] rescue true))
|
99
100
|
end # with_socket
|
100
101
|
|
101
102
|
return(@response)
|
@@ -104,10 +105,14 @@ module Riak
|
|
104
105
|
# Handles the response from the Riak node
|
105
106
|
# @param [String] value The message returned from the Riak node over the TCP Socket
|
106
107
|
# @return [Protobuf::Message] @response the processed response (if any) from the Riak node
|
107
|
-
def
|
108
|
-
@resp_message
|
108
|
+
def parse_response(value)
|
109
|
+
@resp_message << value
|
109
110
|
|
110
|
-
|
111
|
+
value = @buffer + value
|
112
|
+
|
113
|
+
# return {:done => false} if message_remaining?(@resp_message)
|
114
|
+
|
115
|
+
response_chunk, @resp_message_codes, @buffer = decode_message(value)
|
111
116
|
|
112
117
|
@resp_message_codes.each do |resp_mc|
|
113
118
|
if resp_mc.equal?(ERROR_RESPONSE)
|
data/lib/riak/util/decode.rb
CHANGED
@@ -9,9 +9,11 @@ module Riak
|
|
9
9
|
POFF = (PBMC+1)
|
10
10
|
|
11
11
|
def decode_message(message)
|
12
|
+
|
12
13
|
pb_len = 0
|
13
14
|
pb_mc = ''
|
14
15
|
pb_msg = ''
|
16
|
+
remain = ''
|
15
17
|
|
16
18
|
until message.empty?
|
17
19
|
pb_len = message[PLEN].unpack('N')[0] # message[0..3]unpack('N')[0]
|
@@ -20,17 +22,28 @@ module Riak
|
|
20
22
|
prange = POFF..(pb_len+3) # range for the start->finish of the pb message
|
21
23
|
mrange = (pb_len+4)..(message.size-1) # range for any remaining portions of message
|
22
24
|
|
23
|
-
if(prange.count
|
24
|
-
raise FailedExchange.new(prange.count, message[prange].size, message[prange], "decode_error")
|
25
|
-
end
|
25
|
+
break if(prange.count > message[prange].size)
|
26
26
|
|
27
27
|
pb_msg = pb_msg + message[prange]
|
28
28
|
message = message[mrange] # message[(5+pb_len)..(message.size)]
|
29
29
|
end
|
30
30
|
|
31
|
-
[pb_msg, pb_mc.unpack("c" * pb_mc.size)]
|
31
|
+
[pb_msg, pb_mc.unpack("c" * pb_mc.size), message]
|
32
32
|
end
|
33
33
|
|
34
|
+
def message_remaining?(message)
|
35
|
+
pb_len = message[PLEN].unpack('N')[0]
|
36
|
+
msg_len = message.size - PBMC
|
37
|
+
|
38
|
+
puts "pb_len:#{pb_len}"
|
39
|
+
puts "msg_len:#{msg_len}"
|
40
|
+
puts "message:#{message.inspect}"
|
41
|
+
|
42
|
+
return false if pb_len == msg_len
|
43
|
+
return true if pb_len > msg_len
|
44
|
+
|
45
|
+
return message_remaining?(message[(pb_len+4)..(msg_len-1)])
|
46
|
+
end
|
34
47
|
end # module Decode
|
35
48
|
end
|
36
49
|
end
|
data/lib/riak.rb
CHANGED
data/load_stocks.rb
CHANGED
File without changes
|
data/riakpb.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{riakpb}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Scott Gonyea"]
|
9
|
-
s.date = %q{2010-
|
10
|
-
s.description = %q{riakpb is a protocol buffer client for Riak--the distributed database by Basho.
|
9
|
+
s.date = %q{2010-07-08}
|
10
|
+
s.description = %q{riakpb is a protocol buffer client for Riak--the distributed database by Basho.}
|
11
11
|
s.email = %q{me@inherentlylame.com}
|
12
12
|
s.files = ["goog.csv", "History.txt", "lib/riak/bucket.rb", "lib/riak/client/rpc.rb", "lib/riak/client.rb", "lib/riak/client_pb.rb", "lib/riak/failed_exchange.rb", "lib/riak/failed_request.rb", "lib/riak/i18n.rb", "lib/riak/key.rb", "lib/riak/locale/en.yml", "lib/riak/map_reduce.rb", "lib/riak/riak_content.rb", "lib/riak/sibling_error.rb", "lib/riak/util/decode.rb", "lib/riak/util/encode.rb", "lib/riak/util/message_code.rb", "lib/riak/util/translation.rb", "lib/riak.rb", "load_stocks.rb", "Manifest.txt", "Rakefile", "README.rdoc", "riakpb.gemspec", "script/console", "script/destroy", "script/generate", "spec/riak/bucket_spec.rb", "spec/riak/client_spec.rb", "spec/riak/key_spec.rb", "spec/riak/map_reduce_spec.rb", "spec/riak/riak_content_spec.rb", "spec/riak/rpc_spec.rb", "spec/spec_helper.rb"]
|
13
13
|
s.homepage = %q{http://github.com/aitrus/riak-pbclient}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 6
|
9
|
+
version: 0.1.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Scott Gonyea
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-08 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: 0.4.4
|
62
62
|
type: :runtime
|
63
63
|
version_requirements: *id003
|
64
|
-
description: riakpb is a protocol buffer client for Riak--the distributed database by Basho.
|
64
|
+
description: riakpb is a protocol buffer client for Riak--the distributed database by Basho.
|
65
65
|
email: me@inherentlylame.com
|
66
66
|
executables: []
|
67
67
|
|