riak-client 1.4.4.1 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +55 -6
- data/RELEASE_NOTES.md +16 -0
- data/lib/riak.rb +1 -0
- data/lib/riak/client/beefcake/messages.rb +0 -5
- data/lib/riak/client/instrumentation.rb +25 -0
- data/lib/riak/instrumentation.rb +6 -0
- data/lib/riak/util/escape.rb +1 -1
- data/lib/riak/version.rb +1 -1
- data/riak-client.gemspec +2 -1
- data/spec/integration/riak/http_backends_spec.rb +36 -0
- data/spec/riak/escape_spec.rb +12 -12
- data/spec/riak/instrumentation_spec.rb +167 -0
- data/spec/spec_helper.rb +6 -0
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9016aab8aba93bb63aca3046534eda1a37d06df2
|
4
|
+
data.tar.gz: 7fe5882b0b6435b59f335c6dd55b2282f261cdee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b94915ad5556abb0383e804a63b1e1dd4eb95c948552a32c38f8c480a905f5a6d738bc5e1782e0d9f39aab5ae7979bdf09b0549214fa3f2fe4567d53e3165ad3
|
7
|
+
data.tar.gz: 07ab78ccb8117017897415215af4b08e605889a9f5b23f764ed52d7422eefabd329e66a7f4cf3ae5e3a8f59739bfbda1d0be933efc6be52cc5fa9f2d4999b16f
|
data/README.markdown
CHANGED
@@ -80,9 +80,9 @@ results = Riak::MapReduce.new(client).
|
|
80
80
|
link(:bucket => "albums").
|
81
81
|
map("function(v){ return [JSON.parse(v.values[0].data).title]; }", :keep => true).run
|
82
82
|
|
83
|
-
p results # => ["Please Please Me", "With The Beatles", "A Hard Day's Night",
|
83
|
+
p results # => ["Please Please Me", "With The Beatles", "A Hard Day's Night",
|
84
84
|
# "Beatles For Sale", "Help!", "Rubber Soul",
|
85
|
-
# "Revolver", "Sgt. Pepper's Lonely Hearts Club Band", "Magical Mystery Tour",
|
85
|
+
# "Revolver", "Sgt. Pepper's Lonely Hearts Club Band", "Magical Mystery Tour",
|
86
86
|
# "The Beatles", "Yellow Submarine", "Abbey Road", "Let It Be"]
|
87
87
|
```
|
88
88
|
|
@@ -137,7 +137,7 @@ client['users'].disable_index!
|
|
137
137
|
|
138
138
|
## Secondary Index Examples
|
139
139
|
|
140
|
-
Riak supports secondary indexes. Secondary indexing, or "2i," gives you the
|
140
|
+
Riak supports secondary indexes. Secondary indexing, or "2i," gives you the
|
141
141
|
ability to tag objects with multiple queryable values at write time, and then
|
142
142
|
query them later.
|
143
143
|
|
@@ -152,7 +152,7 @@ storage logic is in `lib/riak/rcontent.rb`.
|
|
152
152
|
```ruby
|
153
153
|
object = bucket.get_or_new 'cobb.salad'
|
154
154
|
|
155
|
-
# Indexes end with the "_bin" suffix to indicate they're binary or string
|
155
|
+
# Indexes end with the "_bin" suffix to indicate they're binary or string
|
156
156
|
# indexes. They can have multiple values.
|
157
157
|
object.indexes['ingredients_bin'] = %w{lettuce tomato bacon egg chives}
|
158
158
|
|
@@ -166,7 +166,7 @@ object.store
|
|
166
166
|
|
167
167
|
### Finding Objects
|
168
168
|
|
169
|
-
Secondary index queries return a list of keys exactly matching a scalar or
|
169
|
+
Secondary index queries return a list of keys exactly matching a scalar or
|
170
170
|
within a range.
|
171
171
|
|
172
172
|
```ruby
|
@@ -253,6 +253,55 @@ ArgumentError: Counters can only be incremented or decremented by integers.
|
|
253
253
|
|
254
254
|
That's about it. PN Counters in Riak are distributed, so each node will receive the proper increment/decrement operation. Enjoy using them.
|
255
255
|
|
256
|
+
## Instrumentation
|
257
|
+
|
258
|
+
The Riak client has built-in event hooks for all major over-the-wire operations including:
|
259
|
+
|
260
|
+
* riak.list_buckets
|
261
|
+
* riak.list_keys
|
262
|
+
* riak.set_bucket_props
|
263
|
+
* riak.get_bucket_props
|
264
|
+
* riak.clear_bucket_props
|
265
|
+
* riak.get_index
|
266
|
+
* riak.store_object
|
267
|
+
* riak.get_object
|
268
|
+
* riak.reload_object
|
269
|
+
* riak.delete_object
|
270
|
+
* riak.store_file
|
271
|
+
* riak.get_file
|
272
|
+
* riak.delete_file
|
273
|
+
* riak.file_exists
|
274
|
+
* riak.link_walk
|
275
|
+
* riak.map_reduce
|
276
|
+
* riak.ping
|
277
|
+
|
278
|
+
Events are propogated using [ActiveSupport::Notifications](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html), provided by the [Instrumentable](https://github.com/siyegen/instrumentable) gem.
|
279
|
+
|
280
|
+
### Enabling
|
281
|
+
|
282
|
+
Instrumentation is opt-in. If `instrumentable` is not available, instrumentation will not be available. To turn on instrumentation, simply require the `instrumentable` gem in your app's Gemfile:
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
gem 'instrumentable', '~> 1.1.0'
|
286
|
+
```
|
287
|
+
|
288
|
+
Then, to subscribe to events:
|
289
|
+
|
290
|
+
```ruby
|
291
|
+
ActiveSupport::Notifications.subscribe(/^riak\.*/) do |name, start, finish, id, payload|
|
292
|
+
name # => String, name of the event (such as 'riak.get_object' from above)
|
293
|
+
start # => Time, when the instrumented block started execution
|
294
|
+
finish # => Time, when the instrumented block ended execution
|
295
|
+
id # => String, unique ID for this notification
|
296
|
+
payload # => Hash, the payload
|
297
|
+
end
|
298
|
+
```
|
299
|
+
|
300
|
+
The payload for each event contains the following keys:
|
301
|
+
|
302
|
+
* `:protocol`: The `client.protocol` value of the Riak client
|
303
|
+
* `:client_id`: The client_id of the Riak client
|
304
|
+
* `:_method_args`: The array of method arguments for the instrumented method. For instance, for `riak.get_object`, this value would resemble `[<Riak::Bucket ...>, 'key', {}]`
|
256
305
|
|
257
306
|
## How to Contribute
|
258
307
|
|
@@ -295,5 +344,5 @@ Unless required by applicable law or agreed to in writing, software distributed
|
|
295
344
|
|
296
345
|
## Auxillary Licenses
|
297
346
|
|
298
|
-
The included photo (spec/fixtures/cat.jpg) is Copyright ©2009 [Sean Cribbs](http://seancribbs.com/), and is licensed under the [Creative Commons Attribution Non-Commercial 3.0](http://creativecommons.org/licenses/by-nc/3.0) license.
|
347
|
+
The included photo (spec/fixtures/cat.jpg) is Copyright ©2009 [Sean Cribbs](http://seancribbs.com/), and is licensed under the [Creative Commons Attribution Non-Commercial 3.0](http://creativecommons.org/licenses/by-nc/3.0) license.
|
299
348
|
!["Creative Commons"](http://i.creativecommons.org/l/by-nc/3.0/88x31.png)
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Riak Ruby Client Release Notes
|
2
2
|
|
3
|
+
## 1.4.5 Feature and Bugfix Release - 2014-10-03
|
4
|
+
|
5
|
+
Release 1.4.5 includes:
|
6
|
+
|
7
|
+
Feature:
|
8
|
+
|
9
|
+
* Instrumentation: if the `instrumentable` gem is loaded, the client exposes
|
10
|
+
several event hooks to `ActiveSupport::Notifications`. Read the README for
|
11
|
+
more information, and if you'd like other events to be instrumented, please
|
12
|
+
file GitHub issues. Instrumentation was developed by Ryan Daigle.
|
13
|
+
|
14
|
+
Bugfix:
|
15
|
+
|
16
|
+
* URI escaping now uses the CGI escaper. Thanks to Sean McKibben for
|
17
|
+
reporting this bug.
|
18
|
+
|
3
19
|
## 1.4.4.1 Bugfix Release - 2014-04-17
|
4
20
|
|
5
21
|
Release 1.4.4.1 includes the intended 1.4.4 bugfix:
|
data/lib/riak.rb
CHANGED
@@ -246,11 +246,6 @@ module Riak
|
|
246
246
|
required :props, RpbBucketProps, 2
|
247
247
|
end
|
248
248
|
|
249
|
-
class RpbResetBucketReq
|
250
|
-
include Beefcake::Message
|
251
|
-
required :bucket, :bytes, 1
|
252
|
-
end
|
253
|
-
|
254
249
|
class RpbMapRedReq
|
255
250
|
include Beefcake::Message
|
256
251
|
required :request, :bytes, 1
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Riak::Client
|
2
|
+
include Instrumentable
|
3
|
+
|
4
|
+
client_payload = {protocol: :protocol, client_id: :client_id}
|
5
|
+
|
6
|
+
instrument_method :buckets, 'riak.list_buckets', client_payload
|
7
|
+
instrument_method :list_buckets, 'riak.list_buckets', client_payload
|
8
|
+
instrument_method :list_keys, 'riak.list_keys', client_payload
|
9
|
+
instrument_method :set_bucket_props, 'riak.set_bucket_props', client_payload
|
10
|
+
instrument_method :get_bucket_props, 'riak.get_bucket_props', client_payload
|
11
|
+
instrument_method :clear_bucket_props, 'riak.clear_bucket_props', client_payload
|
12
|
+
instrument_method :get_index, 'riak.get_index', client_payload
|
13
|
+
instrument_method :store_object, 'riak.store_object', client_payload
|
14
|
+
instrument_method :get_object, 'riak.get_object', client_payload
|
15
|
+
instrument_method :reload_object, 'riak.reload_object', client_payload
|
16
|
+
instrument_method :delete_object, 'riak.delete_object', client_payload
|
17
|
+
instrument_method :store_file, 'riak.store_file', client_payload
|
18
|
+
instrument_method :get_file, 'riak.get_file', client_payload
|
19
|
+
instrument_method :delete_file, 'riak.delete_file', client_payload
|
20
|
+
instrument_method :file_exists?, 'riak.file_exists', client_payload
|
21
|
+
instrument_method :file_exist?, 'riak.file_exists', client_payload
|
22
|
+
instrument_method :link_walk, 'riak.link_walk', client_payload
|
23
|
+
instrument_method :mapred, 'riak.map_reduce', client_payload
|
24
|
+
instrument_method :ping, 'riak.ping', client_payload
|
25
|
+
end
|
data/lib/riak/util/escape.rb
CHANGED
data/lib/riak/version.rb
CHANGED
data/riak-client.gemspec
CHANGED
@@ -18,9 +18,10 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_development_dependency "rack", ">=1.0"
|
19
19
|
gem.add_development_dependency "excon", ">=0.6.1"
|
20
20
|
gem.add_development_dependency 'rake'
|
21
|
+
gem.add_development_dependency "instrumentable", "~> 1.1.0"
|
21
22
|
gem.add_runtime_dependency "i18n", ">=0.4.0"
|
22
23
|
gem.add_runtime_dependency "builder", ">= 2.1.2"
|
23
|
-
gem.add_runtime_dependency "beefcake", "~>0.
|
24
|
+
gem.add_runtime_dependency "beefcake", "~>1.0.0"
|
24
25
|
gem.add_runtime_dependency "multi_json", "~>1.0"
|
25
26
|
gem.add_runtime_dependency "innertube", "~>1.0.2"
|
26
27
|
|
@@ -102,6 +102,42 @@ describe "HTTP" do
|
|
102
102
|
stored_file.size.should == string.bytesize
|
103
103
|
end
|
104
104
|
end
|
105
|
+
|
106
|
+
describe 'key and bucket escaping' do
|
107
|
+
let(:default_bucket){ @client[rand(36**10).to_s(36)] }
|
108
|
+
|
109
|
+
{ 'question mark' => 'question?marks',
|
110
|
+
'hash' => 'hashtag#riak',
|
111
|
+
'slash' => 'slash/fiction',
|
112
|
+
'space' => 'space opera',
|
113
|
+
'plus' => 'plus+one',
|
114
|
+
'caret' => 'caret^top',
|
115
|
+
'square bracket' => 'square[]meal',
|
116
|
+
}.each do |k, v|
|
117
|
+
it "doesn't mangle keys with a #{k} in them" do
|
118
|
+
obj = default_bucket.new v
|
119
|
+
obj.content_type = 'text/plain'
|
120
|
+
obj.data = rand(36**10).to_s(36)
|
121
|
+
obj.store
|
122
|
+
|
123
|
+
o2 = nil
|
124
|
+
expect{ o2 = default_bucket.get v }.to_not raise_error
|
125
|
+
expect(o2.data).to eq obj.data
|
126
|
+
end
|
127
|
+
|
128
|
+
it "doesn't mangle buckets with a #{k} in them" do
|
129
|
+
bucket = @client[v]
|
130
|
+
obj = bucket.new rand(36**10).to_s(36)
|
131
|
+
obj.content_type = 'text/plain'
|
132
|
+
obj.data = rand(36**10).to_s(36)
|
133
|
+
obj.store
|
134
|
+
|
135
|
+
o2 = nil
|
136
|
+
expect{ o2 = bucket.get obj.key }.to_not raise_error
|
137
|
+
expect(o2.data).to eq obj.data
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
105
141
|
end
|
106
142
|
end
|
107
143
|
end
|
data/spec/riak/escape_spec.rb
CHANGED
@@ -7,29 +7,29 @@ describe Riak::Util::Escape do
|
|
7
7
|
@object.extend(Riak::Util::Escape)
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
Riak.escaper.should ==
|
10
|
+
it "uses URI by default for escaping" do
|
11
|
+
Riak.escaper.should == CGI
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when using CGI for escaping" do
|
15
15
|
before { @oldesc, Riak.escaper = Riak.escaper, CGI }
|
16
16
|
after { Riak.escaper = @oldesc }
|
17
17
|
|
18
|
-
it "
|
18
|
+
it "escapes standard non-safe characters" do
|
19
19
|
@object.escape("some string").should == "some%20string"
|
20
20
|
@object.escape("another^one").should == "another%5Eone"
|
21
21
|
@object.escape("bracket[one").should == "bracket%5Bone"
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "escapes slashes" do
|
25
25
|
@object.escape("some/inner/path").should == "some%2Finner%2Fpath"
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "converts the bucket or key to a string before escaping" do
|
29
29
|
@object.escape(125).should == '125'
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "unescapes escaped strings" do
|
33
33
|
@object.unescape("some%20string").should == "some string"
|
34
34
|
@object.unescape("another%5Eone").should == "another^one"
|
35
35
|
@object.unescape("bracket%5Bone").should == "bracket[one"
|
@@ -41,30 +41,30 @@ describe Riak::Util::Escape do
|
|
41
41
|
before { @oldesc, Riak.escaper = Riak.escaper, URI }
|
42
42
|
after { Riak.escaper = @oldesc }
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "escapes standard non-safe characters" do
|
45
45
|
@object.escape("some string").should == "some%20string"
|
46
46
|
@object.escape("another^one").should == "another%5Eone"
|
47
47
|
@object.escape("--one+two--").should == "--one%2Btwo--"
|
48
48
|
end
|
49
49
|
|
50
|
-
it "
|
50
|
+
it "allows URI-safe characters" do
|
51
51
|
@object.escape("sean@basho").should == "sean@basho"
|
52
52
|
end
|
53
53
|
|
54
|
-
it "
|
54
|
+
it "escapes slashes" do
|
55
55
|
@object.escape("some/inner/path").should == "some%2Finner%2Fpath"
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "escapes square brackets" do
|
59
59
|
@object.escape("bracket[one").should == "bracket%5Bone"
|
60
60
|
@object.escape("bracket]two").should == "bracket%5Dtwo"
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
63
|
+
it "converts the bucket or key to a string before escaping" do
|
64
64
|
@object.escape(125).should == '125'
|
65
65
|
end
|
66
66
|
|
67
|
-
it "
|
67
|
+
it "unescapes escaped strings" do
|
68
68
|
@object.unescape("some%20string").should == "some string"
|
69
69
|
@object.unescape("another%5Eone").should == "another^one"
|
70
70
|
@object.unescape("bracket%5Bone").should == "bracket[one"
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Riak::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Riak::Client.new
|
7
|
+
@backend = mock("Backend")
|
8
|
+
@client.stub!(:backend).and_yield(@backend)
|
9
|
+
@client.stub!(:http).and_yield(@backend)
|
10
|
+
@bucket = Riak::Bucket.new(@client, "foo")
|
11
|
+
|
12
|
+
@events = []
|
13
|
+
@notifier = ActiveSupport::Notifications.notifier
|
14
|
+
@notifier.subscribe { |*args| (@events ||= []) << event(*args) }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "instrumentation", instrumentation: true do
|
18
|
+
|
19
|
+
it "should notify on the 'buckets' operation" do
|
20
|
+
@backend.should_receive(:list_buckets).and_return(%w{test test2})
|
21
|
+
test_client_event(@client, 'riak.list_buckets') do
|
22
|
+
@client.buckets
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should notify on the 'list_buckets' operation" do
|
27
|
+
@backend.should_receive(:list_buckets).and_return(%w{test test2})
|
28
|
+
test_client_event(@client, 'riak.list_buckets') do
|
29
|
+
@client.list_buckets
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should notify on the 'list_keys' operation" do
|
34
|
+
@backend.should_receive(:list_keys).and_return(%w{test test2})
|
35
|
+
test_client_event(@client, 'riak.list_keys') do
|
36
|
+
@client.list_keys(@bucket)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should notify on the 'get_bucket_props' operation" do
|
41
|
+
@backend.should_receive(:get_bucket_props).and_return({})
|
42
|
+
test_client_event(@client, 'riak.get_bucket_props') do
|
43
|
+
@client.get_bucket_props(@bucket)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should notify on the 'set_bucket_props' operation" do
|
48
|
+
@backend.should_receive(:set_bucket_props).and_return({})
|
49
|
+
test_client_event(@client, 'riak.set_bucket_props') do
|
50
|
+
@client.set_bucket_props(@bucket, {})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should notify on the 'clear_bucket_props' operation" do
|
55
|
+
@backend.should_receive(:clear_bucket_props).and_return({})
|
56
|
+
test_client_event(@client, 'riak.clear_bucket_props') do
|
57
|
+
@client.clear_bucket_props(@bucket)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should notify on the 'get_index' operation" do
|
62
|
+
@backend.should_receive(:get_index).and_return({})
|
63
|
+
test_client_event(@client, 'riak.get_index') do
|
64
|
+
@client.get_index(@bucket, 'index', 'query', {})
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should notify on the 'get_object' operation" do
|
69
|
+
@backend.should_receive(:fetch_object).and_return(nil)
|
70
|
+
test_client_event(@client, 'riak.get_object') do
|
71
|
+
@client.get_object(@bucket, 'bar')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should notify on the 'store_object' operation" do
|
76
|
+
@backend.should_receive(:store_object).and_return(nil)
|
77
|
+
test_client_event(@client, 'riak.store_object') do
|
78
|
+
@client.store_object(Object.new)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should notify on the 'reload_object' operation" do
|
83
|
+
@backend.should_receive(:reload_object).and_return(nil)
|
84
|
+
test_client_event(@client, 'riak.reload_object') do
|
85
|
+
@client.reload_object(Object.new)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should notify on the 'delete_object' operation" do
|
90
|
+
@backend.should_receive(:delete_object).and_return(nil)
|
91
|
+
test_client_event(@client, 'riak.delete_object') do
|
92
|
+
@client.delete_object(@bucket, 'bar')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should notify on the 'store_file' operation" do
|
97
|
+
@backend.should_receive(:store_file).and_return(nil)
|
98
|
+
test_client_event(@client, 'riak.store_file') do
|
99
|
+
@client.store_file('filename')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should notify on the 'get_file' operation" do
|
104
|
+
@backend.should_receive(:get_file).and_return(nil)
|
105
|
+
test_client_event(@client, 'riak.get_file') do
|
106
|
+
@client.get_file('filename')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should notify on the 'delete_file' operation" do
|
111
|
+
@backend.should_receive(:delete_file).and_return(nil)
|
112
|
+
test_client_event(@client, 'riak.delete_file') do
|
113
|
+
@client.delete_file('filename')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should notify on the 'file_exists' operation" do
|
118
|
+
@backend.should_receive(:file_exists?).and_return(nil)
|
119
|
+
test_client_event(@client, 'riak.file_exists') do
|
120
|
+
@client.file_exists?('filename')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should notify on the 'file_exist' operation" do
|
125
|
+
@backend.should_receive(:file_exists?).and_return(nil)
|
126
|
+
test_client_event(@client, 'riak.file_exists') do
|
127
|
+
@client.file_exist?('filename')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should notify on the 'link_walk' operation" do
|
132
|
+
@backend.should_receive(:link_walk).and_return(nil)
|
133
|
+
test_client_event(@client, 'riak.link_walk') do
|
134
|
+
@client.link_walk(Object.new, [Riak::WalkSpec.new(:bucket => 'foo')])
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should notify on the 'mapred' operation" do
|
139
|
+
@mapred = Riak::MapReduce.new(@client).add('test').map("function(){}").map("function(){}")
|
140
|
+
@backend.should_receive(:mapred).and_return(nil)
|
141
|
+
test_client_event(@client, 'riak.map_reduce') do
|
142
|
+
@client.mapred(@mapred)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should notify on the 'ping' operation" do
|
147
|
+
@backend.should_receive(:ping).and_return(nil)
|
148
|
+
test_client_event(@client, 'riak.ping') do
|
149
|
+
@client.ping
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_client_event(client, event_name, &block)
|
156
|
+
block.call
|
157
|
+
@events.size.should == 1
|
158
|
+
event = @events.first
|
159
|
+
event.name.should == event_name
|
160
|
+
event.payload[:protocol].should == client.protocol
|
161
|
+
event.payload[:client_id].should == client.client_id
|
162
|
+
end
|
163
|
+
|
164
|
+
# name, start, finish, id, payload
|
165
|
+
def event(*args)
|
166
|
+
ActiveSupport::Notifications::Event.new(*args)
|
167
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riak-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Cribbs
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: instrumentable
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.1.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.1.0
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: i18n
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,14 +129,14 @@ dependencies:
|
|
115
129
|
requirements:
|
116
130
|
- - "~>"
|
117
131
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.
|
132
|
+
version: 1.0.0
|
119
133
|
type: :runtime
|
120
134
|
prerelease: false
|
121
135
|
version_requirements: !ruby/object:Gem::Requirement
|
122
136
|
requirements:
|
123
137
|
- - "~>"
|
124
138
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
139
|
+
version: 1.0.0
|
126
140
|
- !ruby/object:Gem::Dependency
|
127
141
|
name: multi_json
|
128
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,6 +208,7 @@ files:
|
|
194
208
|
- lib/riak/client/http_backend/object_methods.rb
|
195
209
|
- lib/riak/client/http_backend/request_headers.rb
|
196
210
|
- lib/riak/client/http_backend/transport_methods.rb
|
211
|
+
- lib/riak/client/instrumentation.rb
|
197
212
|
- lib/riak/client/net_http_backend.rb
|
198
213
|
- lib/riak/client/node.rb
|
199
214
|
- lib/riak/client/protobuffs_backend.rb
|
@@ -214,6 +229,7 @@ files:
|
|
214
229
|
- lib/riak/failed_request.rb
|
215
230
|
- lib/riak/i18n.rb
|
216
231
|
- lib/riak/index_collection.rb
|
232
|
+
- lib/riak/instrumentation.rb
|
217
233
|
- lib/riak/json.rb
|
218
234
|
- lib/riak/link.rb
|
219
235
|
- lib/riak/list_buckets.rb
|
@@ -283,6 +299,7 @@ files:
|
|
283
299
|
- spec/riak/http_backend/transport_methods_spec.rb
|
284
300
|
- spec/riak/http_backend_spec.rb
|
285
301
|
- spec/riak/index_collection_spec.rb
|
302
|
+
- spec/riak/instrumentation_spec.rb
|
286
303
|
- spec/riak/link_spec.rb
|
287
304
|
- spec/riak/list_buckets_spec.rb
|
288
305
|
- spec/riak/map_reduce/filter_builder_spec.rb
|
@@ -371,6 +388,7 @@ test_files:
|
|
371
388
|
- spec/riak/http_backend/transport_methods_spec.rb
|
372
389
|
- spec/riak/http_backend_spec.rb
|
373
390
|
- spec/riak/index_collection_spec.rb
|
391
|
+
- spec/riak/instrumentation_spec.rb
|
374
392
|
- spec/riak/link_spec.rb
|
375
393
|
- spec/riak/list_buckets_spec.rb
|
376
394
|
- spec/riak/map_reduce/filter_builder_spec.rb
|