riak-client 2.2.0.pre1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +0 -2
  4. data/README.markdown +11 -7
  5. data/RELEASE_NOTES.md +29 -2
  6. data/Rakefile +5 -3
  7. data/lib/riak/bucket.rb +55 -23
  8. data/lib/riak/bucket_properties.rb +8 -1
  9. data/lib/riak/bucket_type.rb +29 -0
  10. data/lib/riak/bucket_typed/bucket.rb +15 -7
  11. data/lib/riak/client.rb +24 -8
  12. data/lib/riak/client/beefcake/bucket_properties_operator.rb +8 -8
  13. data/lib/riak/client/beefcake/crdt/set_loader.rb +1 -1
  14. data/lib/riak/client/beefcake/crdt_loader.rb +1 -1
  15. data/lib/riak/client/beefcake/crdt_operator.rb +9 -9
  16. data/lib/riak/client/beefcake/message_codes.rb +4 -0
  17. data/lib/riak/client/beefcake/message_overlay.rb +4 -0
  18. data/lib/riak/client/beefcake/messages.rb +35 -5
  19. data/lib/riak/client/beefcake/object_methods.rb +21 -13
  20. data/lib/riak/client/beefcake/protocol.rb +7 -7
  21. data/lib/riak/client/beefcake/socket.rb +2 -2
  22. data/lib/riak/client/beefcake_protobuffs_backend.rb +58 -33
  23. data/lib/riak/client/protobuffs_backend.rb +5 -5
  24. data/lib/riak/client/yokozuna.rb +3 -3
  25. data/lib/riak/core_ext/deep_dup.rb +1 -1
  26. data/lib/riak/counter.rb +10 -10
  27. data/lib/riak/crdt/base.rb +39 -21
  28. data/lib/riak/crdt/batch_counter.rb +5 -5
  29. data/lib/riak/crdt/batch_map.rb +2 -2
  30. data/lib/riak/crdt/counter.rb +7 -7
  31. data/lib/riak/crdt/inner_counter.rb +4 -4
  32. data/lib/riak/crdt/inner_flag.rb +3 -3
  33. data/lib/riak/crdt/inner_map.rb +1 -1
  34. data/lib/riak/crdt/inner_register.rb +1 -1
  35. data/lib/riak/crdt/inner_set.rb +5 -5
  36. data/lib/riak/crdt/map.rb +9 -9
  37. data/lib/riak/crdt/set.rb +10 -10
  38. data/lib/riak/crdt/typed_collection.rb +39 -36
  39. data/lib/riak/errors/base.rb +1 -1
  40. data/lib/riak/errors/crdt_error.rb +20 -0
  41. data/lib/riak/errors/search_error.rb +6 -0
  42. data/lib/riak/index_collection.rb +1 -1
  43. data/lib/riak/link.rb +5 -3
  44. data/lib/riak/locale/en.yml +5 -1
  45. data/lib/riak/map_reduce.rb +7 -7
  46. data/lib/riak/map_reduce/filter_builder.rb +2 -2
  47. data/lib/riak/map_reduce/phase.rb +2 -2
  48. data/lib/riak/preflist_item.rb +7 -0
  49. data/lib/riak/rcontent.rb +8 -8
  50. data/lib/riak/robject.rb +27 -14
  51. data/lib/riak/search.rb +1 -0
  52. data/lib/riak/search/index.rb +17 -3
  53. data/lib/riak/search/query.rb +14 -6
  54. data/lib/riak/search/result_collection.rb +56 -3
  55. data/lib/riak/search/result_document.rb +71 -1
  56. data/lib/riak/search/schema.rb +6 -6
  57. data/lib/riak/secondary_index.rb +20 -12
  58. data/lib/riak/serializers.rb +0 -1
  59. data/lib/riak/util/escape.rb +2 -2
  60. data/lib/riak/util/translation.rb +1 -2
  61. data/lib/riak/version.rb +1 -1
  62. data/lib/riak/walk_spec.rb +67 -32
  63. data/riak-client.gemspec +5 -4
  64. data/spec/integration/riak/bucket_types_spec.rb +35 -5
  65. data/spec/integration/riak/conflict_resolution_spec.rb +1 -1
  66. data/spec/integration/riak/counters_spec.rb +1 -1
  67. data/spec/integration/riak/crdt/configuration_spec.rb +37 -0
  68. data/spec/integration/riak/crdt_search_spec.rb +176 -0
  69. data/spec/integration/riak/crdt_spec.rb +9 -33
  70. data/spec/integration/riak/crdt_validation/map_spec.rb +4 -4
  71. data/spec/integration/riak/crdt_validation/set_spec.rb +13 -13
  72. data/spec/integration/riak/preflist_spec.rb +31 -0
  73. data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +2 -2
  74. data/spec/integration/riak/protobuffs_backends_spec.rb +9 -2
  75. data/spec/integration/riak/search_spec.rb +3 -3
  76. data/spec/integration/riak/secondary_index_spec.rb +3 -3
  77. data/spec/integration/riak/security_spec.rb +7 -7
  78. data/spec/integration/yokozuna/queries_spec.rb +1 -1
  79. data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +9 -9
  80. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +9 -9
  81. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +5 -5
  82. data/spec/riak/beefcake_protobuffs_backend_spec.rb +8 -8
  83. data/spec/riak/bucket_properties_spec.rb +27 -6
  84. data/spec/riak/bucket_spec.rb +5 -5
  85. data/spec/riak/bucket_type_spec.rb +21 -5
  86. data/spec/riak/bucket_typed/bucket_spec.rb +62 -0
  87. data/spec/riak/client_spec.rb +36 -18
  88. data/spec/riak/counter_spec.rb +4 -4
  89. data/spec/riak/crdt/counter_spec.rb +2 -2
  90. data/spec/riak/crdt/inner_flag_spec.rb +2 -2
  91. data/spec/riak/crdt/inner_map_spec.rb +4 -4
  92. data/spec/riak/crdt/inner_register_spec.rb +1 -1
  93. data/spec/riak/crdt/map_spec.rb +4 -4
  94. data/spec/riak/crdt/shared_examples.rb +5 -5
  95. data/spec/riak/crdt/typed_collection_spec.rb +21 -21
  96. data/spec/riak/map_reduce/filter_builder_spec.rb +2 -2
  97. data/spec/riak/map_reduce/phase_spec.rb +4 -4
  98. data/spec/riak/map_reduce_spec.rb +60 -42
  99. data/spec/riak/multiget_spec.rb +2 -2
  100. data/spec/riak/robject_spec.rb +55 -14
  101. data/spec/riak/search/index_spec.rb +12 -2
  102. data/spec/riak/search/query_spec.rb +4 -4
  103. data/spec/riak/search/result_collection_spec.rb +6 -4
  104. data/spec/riak/search/result_document_spec.rb +52 -9
  105. data/spec/riak/search/schema_spec.rb +2 -2
  106. data/spec/riak/secondary_index_spec.rb +6 -6
  107. data/spec/riak/serializers_spec.rb +27 -10
  108. data/spec/riak/walk_spec_spec.rb +10 -6
  109. data/spec/spec_helper.rb +11 -2
  110. data/spec/support/crdt_search_config.rb +112 -0
  111. data/spec/support/crdt_search_fixtures.rb +42 -0
  112. data/spec/support/search_config.rb +7 -5
  113. data/spec/support/search_corpus_setup.rb +2 -2
  114. data/spec/support/test_client.rb +2 -2
  115. data/spec/support/unified_backend_examples.rb +5 -5
  116. data/spec/support/version_filter.rb +5 -3
  117. data/spec/support/wait_until.rb +9 -3
  118. metadata +36 -13
  119. data/spec/riak/bucket_typed/bucket.rb +0 -43
data/lib/riak/client.rb CHANGED
@@ -12,11 +12,14 @@ require 'riak/client/node'
12
12
  require 'riak/client/search'
13
13
  require 'riak/client/yokozuna'
14
14
  require 'riak/client/protobuffs_backend'
15
+ require 'riak/preflist_item'
15
16
  require 'riak/client/beefcake_protobuffs_backend'
16
17
  require 'riak/bucket'
18
+ require 'riak/bucket_properties'
17
19
  require 'riak/bucket_type'
18
20
  require 'riak/multiget'
19
21
  require 'riak/secondary_index'
22
+ require 'riak/search'
20
23
  require 'riak/stamp'
21
24
  require 'riak/list_buckets'
22
25
 
@@ -81,7 +84,7 @@ module Riak
81
84
  # @option options [Fixnum, String] :client_id (rand(MAX_CLIENT_ID)) The internal client ID used by Riak to route responses
82
85
  # @option options [String, Symbol] :protobuffs_backend (:Beefcake) which Protocol Buffers backend to use
83
86
  # @raise [ArgumentError] raised if any invalid options are given
84
- def initialize(options={})
87
+ def initialize(options = {})
85
88
  if options.include? :port
86
89
  warn(t('deprecated.port', :backtrace => caller[0..2].join("\n ")))
87
90
  end
@@ -120,7 +123,7 @@ module Riak
120
123
  # @param [Hash] options options for retrieving the bucket
121
124
  # @option options [Boolean] :props (false) whether to retreive the bucket properties
122
125
  # @return [Bucket] the requested bucket
123
- def bucket(name, options={})
126
+ def bucket(name, options = {})
124
127
  raise ArgumentError, t('zero_length_bucket') if name == ''
125
128
  unless (options.keys - [:props]).empty?
126
129
  raise ArgumentError, "invalid options"
@@ -140,7 +143,7 @@ module Riak
140
143
  # @note This is an expensive operation and should be used only
141
144
  # in development.
142
145
  # @return [Array<Bucket>] a list of buckets
143
- def buckets(options={}, &block)
146
+ def buckets(options = {}, &block)
144
147
  warn(t('list_buckets', :backtrace => caller.join("\n "))) unless Riak.disable_list_keys_warnings
145
148
 
146
149
  return ListBuckets.new self, options, block if block_given?
@@ -224,19 +227,32 @@ module Riak
224
227
  end
225
228
 
226
229
  # Bucket properties. See Bucket#props
227
- def get_bucket_props(bucket, options={ })
230
+ def get_bucket_props(bucket, options = { })
228
231
  backend do |b|
229
232
  b.get_bucket_props bucket, options
230
233
  end
231
234
  end
232
235
 
233
236
  # Queries a secondary index on a bucket. See Bucket#get_index
234
- def get_index(bucket, index, query, options={})
237
+ def get_index(bucket, index, query, options = {})
235
238
  backend do |b|
236
239
  b.get_index bucket, index, query, options
237
240
  end
238
241
  end
239
242
 
243
+ # Retrieves a preflist for the given bucket, key, and type; useful for
244
+ # figuring out where in the cluster an object is stored.
245
+ # @param [Bucket, String] bucket the Bucket or name of the bucket
246
+ # @param [String] key the key
247
+ # @param [BucketType, String] type the bucket type or name of the bucket
248
+ # type
249
+ # @return [Array<PreflistItem>] an array of preflist entries
250
+ def get_preflist(bucket, key, type = nil, options = { })
251
+ backend do |b|
252
+ b.get_preflist bucket, key, type, options
253
+ end
254
+ end
255
+
240
256
  # Get multiple objects in parallel.
241
257
  def get_many(pairs)
242
258
  Multiget.get_all self, pairs
@@ -256,7 +272,7 @@ module Riak
256
272
  end
257
273
 
258
274
  # Retrieves a list of keys in the given bucket. See Bucket#keys
259
- def list_keys(bucket, options={}, &block)
275
+ def list_keys(bucket, options = {}, &block)
260
276
  if block_given?
261
277
  backend do |b|
262
278
  b.list_keys bucket, options, &block
@@ -367,14 +383,14 @@ module Riak
367
383
  end
368
384
 
369
385
  # Sets the properties on a bucket. See Bucket#props=
370
- def set_bucket_props(bucket, properties, type=nil)
386
+ def set_bucket_props(bucket, properties, type = nil)
371
387
  backend do |b|
372
388
  b.set_bucket_props(bucket, properties, type)
373
389
  end
374
390
  end
375
391
 
376
392
  # Clears the properties on a bucket. See Bucket#clear_props
377
- def clear_bucket_props(bucket, options={ })
393
+ def clear_bucket_props(bucket, options = { })
378
394
  backend do |b|
379
395
  b.reset_bucket_props(bucket, options)
380
396
  end
@@ -13,7 +13,7 @@ class Riak::Client::BeefcakeProtobuffsBackend
13
13
  @backend = backend
14
14
  end
15
15
 
16
- def get(bucket, options={})
16
+ def get(bucket, options = {})
17
17
  response = backend.protocol do |p|
18
18
  p.write :GetBucketReq, get_request(bucket, options)
19
19
  p.expect :GetBucketResp, RpbGetBucketResp
@@ -24,11 +24,11 @@ class Riak::Client::BeefcakeProtobuffsBackend
24
24
  return rubyfy(properties)
25
25
  end
26
26
 
27
- def put(bucket, props={}, options={})
27
+ def put(bucket, props = {}, options = {})
28
28
  properties = riakify props
29
29
 
30
30
  request = put_request bucket, properties, options
31
-
31
+
32
32
  backend.protocol do |p|
33
33
  p.write :SetBucketReq, request
34
34
  p.expect :SetBucketResp
@@ -42,7 +42,7 @@ class Riak::Client::BeefcakeProtobuffsBackend
42
42
  rubyfy_quorums(props)
43
43
  rubyfy_hooks(props)
44
44
  rubyfy_modfuns(props)
45
-
45
+
46
46
  return props
47
47
  end
48
48
 
@@ -126,7 +126,7 @@ class Riak::Client::BeefcakeProtobuffsBackend
126
126
  end
127
127
 
128
128
  def rubyfy_modfun(modfun)
129
- {
129
+ {
130
130
  'mod' => modfun[:module],
131
131
  'fun' => modfun[:function]
132
132
  }
@@ -151,16 +151,16 @@ class Riak::Client::BeefcakeProtobuffsBackend
151
151
  3
152
152
  end
153
153
  end
154
-
154
+
155
155
  def name_options(bucket)
156
156
  o = {}
157
157
  if bucket.is_a? Riak::Bucket
158
- o[:bucket] = bucket.name
158
+ o[:bucket] = bucket.name
159
159
  o[:type] = bucket.type.name if bucket.needs_type?
160
160
  else
161
161
  o[:bucket] = bucket
162
162
  end
163
-
163
+
164
164
  return o
165
165
  end
166
166
 
@@ -15,4 +15,4 @@ class Riak::Client::BeefcakeProtobuffsBackend
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -26,7 +26,7 @@ module Riak
26
26
  end
27
27
 
28
28
  # Perform the protobuffs request and return a deserialized CRDT.
29
- def load(bucket, key, bucket_type, options={})
29
+ def load(bucket, key, bucket_type, options = {})
30
30
  bucket = bucket.name if bucket.is_a? ::Riak::Bucket
31
31
  fetch_args = options.merge(
32
32
  bucket: bucket,
@@ -4,13 +4,13 @@ module Riak
4
4
  class Client
5
5
  class BeefcakeProtobuffsBackend
6
6
 
7
- # Returns a new {CrdtOperator} for serializing CRDT operations into
7
+ # Returns a new {CrdtOperator} for serializing CRDT operations into
8
8
  # protobuffs and sending them to a Riak cluster.
9
9
  # @api private
10
10
  def crdt_operator
11
11
  return CrdtOperator.new self
12
12
  end
13
-
13
+
14
14
  # Serializes and writes CRDT operations from {Riak::Crdt::Operation} members
15
15
  # into protobuffs, and writes them to a Riak cluster.
16
16
  # @api private
@@ -18,13 +18,13 @@ module Riak
18
18
  include Util::Translation
19
19
 
20
20
  attr_reader :backend
21
-
21
+
22
22
  def initialize(backend)
23
23
  @backend = backend
24
24
  end
25
25
 
26
26
  # Serializes and writes CRDT operations.
27
- def operate(bucket, key, bucket_type, operation, options={})
27
+ def operate(bucket, key, bucket_type, operation, options = {})
28
28
  serialized = serialize(operation)
29
29
  args = {
30
30
  bucket: bucket,
@@ -63,7 +63,7 @@ module Riak
63
63
  def wrap_field_for(ops)
64
64
  "#{ops.first.type.to_s}_op".to_sym
65
65
  end
66
-
66
+
67
67
  def serialize_group(operations)
68
68
  case operations.first.type
69
69
  when :counter
@@ -76,9 +76,9 @@ module Riak
76
76
  raise ArgumentError, t('crdt.unknown_field', symbol: operation.type.inspect)
77
77
  end
78
78
  end
79
-
79
+
80
80
  def inner_serialize_group(operations)
81
- updates, deletes = operations.partition do |op|
81
+ updates, deletes = operations.partition do |op|
82
82
  op.value.is_a? Riak::Crdt::Operation::Update
83
83
  end
84
84
  serialized_updates = updates.map do |operation|
@@ -117,7 +117,7 @@ module Riak
117
117
  type: type_symbol_to_type_enum(operation.type)
118
118
  )
119
119
  end
120
-
120
+
121
121
  def serialize_counter(counter_ops)
122
122
  amount = counter_ops.inject(0){|m, o| m += o.value }
123
123
  CounterOp.new(increment: amount)
@@ -163,7 +163,7 @@ module Riak
163
163
  adds.add [o.value[:add]] if o.value[:add]
164
164
  removes.merge [o.value[:remove]] if o.value[:remove]
165
165
  end
166
-
166
+
167
167
  SetOp.new(
168
168
  adds: adds.to_a.flatten,
169
169
  removes: removes.to_a.flatten
@@ -39,6 +39,10 @@ module Riak
39
39
  :SetBucketTypeReq => 32,
40
40
  :ResetBucketTypeReq => 33,
41
41
 
42
+ # preflist
43
+ :GetBucketKeyPreflistReq => 33,
44
+ :GetBucketKeyPreflistResp => 34,
45
+
42
46
  # riak cs
43
47
  :CSBucketReq => 40,
44
48
  :CSBucketResp => 41,
@@ -9,6 +9,10 @@ module Riak
9
9
  end
10
10
  end
11
11
 
12
+ class RpbBucketKeyPreflistItem
13
+ include Riak::PreflistItem
14
+ end
15
+
12
16
  class RpbBucketProps
13
17
 
14
18
  # "repeated" elements with zero items are indistinguishable
@@ -4,7 +4,7 @@ module Riak
4
4
  class Client
5
5
  # @private
6
6
  class BeefcakeProtobuffsBackend
7
- ## Generated from riak.proto for
7
+ ## Generated from riak.proto for
8
8
  require "beefcake"
9
9
 
10
10
 
@@ -149,13 +149,14 @@ class RpbBucketProps
149
149
  optional :search_index, :bytes, 25
150
150
  optional :datatype, :bytes, 26
151
151
  optional :consistent, :bool, 27
152
+ optional :write_once, :bool, 28
152
153
  end
153
154
 
154
155
  class RpbAuthReq
155
156
  required :user, :bytes, 1
156
157
  required :password, :bytes, 2
157
158
  end
158
- ## Generated from riak_kv.proto for
159
+ ## Generated from riak_kv.proto for
159
160
  require "beefcake"
160
161
 
161
162
 
@@ -260,6 +261,18 @@ class RpbCounterGetResp
260
261
  include Beefcake::Message
261
262
  end
262
263
 
264
+ class RpbGetBucketKeyPreflistReq
265
+ include Beefcake::Message
266
+ end
267
+
268
+ class RpbGetBucketKeyPreflistResp
269
+ include Beefcake::Message
270
+ end
271
+
272
+ class RpbBucketKeyPreflistItem
273
+ include Beefcake::Message
274
+ end
275
+
263
276
  class RpbGetClientIdResp
264
277
  required :client_id, :bytes, 1
265
278
  end
@@ -457,7 +470,23 @@ end
457
470
  class RpbCounterGetResp
458
471
  optional :value, :sint64, 1
459
472
  end
460
- ## Generated from riak_search.proto for
473
+
474
+ class RpbGetBucketKeyPreflistReq
475
+ required :bucket, :bytes, 1
476
+ required :key, :bytes, 2
477
+ optional :type, :bytes, 3
478
+ end
479
+
480
+ class RpbGetBucketKeyPreflistResp
481
+ repeated :preflist, RpbBucketKeyPreflistItem, 1
482
+ end
483
+
484
+ class RpbBucketKeyPreflistItem
485
+ required :partition, :int64, 1
486
+ required :node, :bytes, 2
487
+ required :primary, :bool, 3
488
+ end
489
+ ## Generated from riak_search.proto for
461
490
  require "beefcake"
462
491
 
463
492
 
@@ -495,7 +524,7 @@ class RpbSearchQueryResp
495
524
  optional :max_score, :float, 2
496
525
  optional :num_found, :uint32, 3
497
526
  end
498
- ## Generated from riak_yokozuna.proto for
527
+ ## Generated from riak_yokozuna.proto for
499
528
  require "beefcake"
500
529
 
501
530
 
@@ -551,6 +580,7 @@ end
551
580
 
552
581
  class RpbYokozunaIndexPutReq
553
582
  required :index, RpbYokozunaIndex, 1
583
+ optional :timeout, :uint32, 2
554
584
  end
555
585
 
556
586
  class RpbYokozunaIndexDeleteReq
@@ -573,7 +603,7 @@ end
573
603
  class RpbYokozunaSchemaGetResp
574
604
  required :schema, RpbYokozunaSchema, 1
575
605
  end
576
- ## Generated from riak_dt.proto for
606
+ ## Generated from riak_dt.proto for
577
607
  require "beefcake"
578
608
 
579
609
 
@@ -9,20 +9,15 @@ module Riak
9
9
  ENCODING = "Riak".respond_to?(:encoding)
10
10
 
11
11
  # Returns RpbPutReq
12
- def dump_object(robject, options={})
13
- pbuf = RpbPutReq.new(options.merge(:bucket => maybe_encode(robject.bucket.name)))
12
+ def dump_object(robject, options = {})
13
+ req_opts = options.merge(:bucket => maybe_encode(robject.bucket.name))
14
+ if robject.bucket.respond_to?(:type) && t = robject.bucket.type
15
+ req_opts[:type] = maybe_encode(t.name)
16
+ end
17
+ pbuf = RpbPutReq.new(req_opts)
14
18
  pbuf.key = maybe_encode(robject.key) if robject.key # Put w/o key supported!
15
19
  pbuf.vclock = maybe_encode(Base64.decode64(robject.vclock)) if robject.vclock
16
- pbuf.content = RpbContent.new(:value => maybe_encode(robject.raw_data),
17
- :content_type => maybe_encode(robject.content_type),
18
- :links => robject.links.map {|l| encode_link(l) }.compact,
19
- :indexes => robject.indexes.map {|k,s| encode_index(k,s) }.flatten)
20
-
21
- pbuf.content.usermeta = robject.meta.map {|k,v| encode_meta(k,v)} if robject.meta.any?
22
- pbuf.content.vtag = maybe_encode(robject.etag) if robject.etag.present?
23
- if ENCODING # 1.9 support
24
- pbuf.content.charset = maybe_encode(robject.raw_data.encoding.name)
25
- end
20
+ dump_content pbuf, robject
26
21
  pbuf
27
22
  end
28
23
 
@@ -60,6 +55,19 @@ module Riak
60
55
  rcontent
61
56
  end
62
57
 
58
+ def dump_content(pbuf, robject)
59
+ pbuf.content = RpbContent.new(:value => maybe_encode(robject.raw_data),
60
+ :content_type => maybe_encode(robject.content_type),
61
+ :links => robject.links.map {|l| encode_link(l) }.compact,
62
+ :indexes => robject.indexes.map {|k, s| encode_index(k, s) }.flatten)
63
+
64
+ pbuf.content.usermeta = robject.meta.map {|k, v| encode_meta(k, v)} if robject.meta.any?
65
+ pbuf.content.vtag = maybe_encode(robject.etag) if robject.etag.present?
66
+ if ENCODING # 1.9 support
67
+ pbuf.content.charset = maybe_encode(robject.raw_data.encoding.name)
68
+ end
69
+ end
70
+
63
71
  def decode_link(pbuf)
64
72
  Riak::Link.new(pbuf.bucket, pbuf.key, pbuf.tag)
65
73
  end
@@ -75,7 +83,7 @@ module Riak
75
83
  hash[pbuf.key] = pbuf.value
76
84
  end
77
85
 
78
- def encode_meta(key,value)
86
+ def encode_meta(key, value)
79
87
  return nil unless value.present?
80
88
  RpbPair.new(:key => maybe_encode(key.to_s),
81
89
  :value => maybe_encode(value.to_s))
@@ -16,12 +16,12 @@ module Riak
16
16
 
17
17
  # Encodes and writes a Riak-formatted message, including protocol buffer
18
18
  # payload if given.
19
- #
20
- # @param [Symbol, Integer] code the symbolic or numeric code for the
19
+ #
20
+ # @param [Symbol, Integer] code the symbolic or numeric code for the
21
21
  # message
22
22
  # @param [Beefcake::Message, nil] message the protocol buffer message
23
23
  # payload, or nil if the message carries no payload
24
- def write(code, message=nil)
24
+ def write(code, message = nil)
25
25
  if code.is_a? Symbol
26
26
  code = BeefcakeMessageCodes.index code
27
27
  end
@@ -42,7 +42,7 @@ module Riak
42
42
  # @return [Array<Symbol, String>]
43
43
  def receive
44
44
  header = socket.read 5
45
-
45
+
46
46
  raise ProtobuffsFailedHeader.new if header.nil?
47
47
  message_length, code = header.unpack 'NC'
48
48
  body_length = message_length - 1
@@ -59,7 +59,7 @@ module Riak
59
59
  # success if the payload is empty.
60
60
  #
61
61
  # @param [Symbol] code the code for the message
62
- # @param [Class, nil] decoder_class the class to attempt to decode
62
+ # @param [Class, nil] decoder_class the class to attempt to decode
63
63
  # the payload with
64
64
  # @param [Hash] options
65
65
  # @option options [Boolean] :empty_body_acceptable Whether to accept
@@ -71,10 +71,10 @@ module Riak
71
71
  # 255-ErrorResp
72
72
  # @raise {ProtobuffsUnexpectedResponse} if the message from riak did
73
73
  # not match `code`
74
- def expect(code, decoder_class=nil, options={ })
74
+ def expect(code, decoder_class = nil, options = { })
75
75
  code = BeefcakeMessageCodes[code] unless code.is_a? Symbol
76
76
  name, body = receive
77
-
77
+
78
78
  if name == :ErrorResp
79
79
  raise ProtobuffsErrorResponse.new RpbErrorResp.decode(body)
80
80
  end