Class: Riak::Client::BeefcakeProtobuffsBackend
- Inherits:
-
ProtobuffsBackend
show all
- Includes:
- ObjectMethods
- Defined in:
- lib/riak/client/beefcake/messages.rb,
lib/riak/client/beefcake/socket.rb,
lib/riak/client/beefcake/operator.rb,
lib/riak/client/beefcake/protocol.rb,
lib/riak/client/beefcake/crdt_loader.rb,
lib/riak/client/beefcake/crdt_operator.rb,
lib/riak/client/beefcake/ts_cell_codec.rb,
lib/riak/client/beefcake/object_methods.rb,
lib/riak/client/beefcake/crdt/map_loader.rb,
lib/riak/client/beefcake/crdt/set_loader.rb,
lib/riak/client/beefcake/message_overlay.rb,
lib/riak/client/beefcake_protobuffs_backend.rb,
lib/riak/client/beefcake/crdt/counter_loader.rb,
lib/riak/client/beefcake/time_series_get_operator.rb,
lib/riak/client/beefcake/time_series_put_operator.rb,
lib/riak/client/beefcake/crdt/grow_only_set_loader.rb,
lib/riak/client/beefcake/crdt/hyper_log_log_loader.rb,
lib/riak/client/beefcake/time_series_list_operator.rb,
lib/riak/client/beefcake/bucket_properties_operator.rb,
lib/riak/client/beefcake/time_series_query_operator.rb,
lib/riak/client/beefcake/time_series_delete_operator.rb
Overview
Copyright 2010-present Basho Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Modules: ObjectMethods, TsColumnType
Classes: BeefcakeSocket, BucketPropertiesOperator, CounterOp, CrdtLoader, CrdtOperator, DtFetchReq, DtFetchResp, DtOp, DtUpdateReq, DtUpdateResp, DtValue, GSetOp, HllOp, MapEntry, MapField, MapOp, MapUpdate, Operator, Protocol, RpbAuthReq, RpbBucketKeyPreflistItem, RpbBucketProps, RpbCSBucketReq, RpbCSBucketResp, RpbCommitHook, RpbContent, RpbCounterGetReq, RpbCounterGetResp, RpbCounterUpdateReq, RpbCounterUpdateResp, RpbCoverageEntry, RpbCoverageReq, RpbCoverageResp, RpbDelReq, RpbErrorResp, RpbGetBucketKeyPreflistReq, RpbGetBucketKeyPreflistResp, RpbGetBucketReq, RpbGetBucketResp, RpbGetBucketTypeReq, RpbGetClientIdResp, RpbGetReq, RpbGetResp, RpbGetServerInfoResp, RpbIndexBodyResp, RpbIndexObject, RpbIndexReq, RpbIndexResp, RpbLink, RpbListBucketsReq, RpbListBucketsResp, RpbListKeysReq, RpbListKeysResp, RpbMapRedReq, RpbMapRedResp, RpbModFun, RpbPair, RpbPutReq, RpbPutResp, RpbResetBucketReq, RpbSearchDoc, RpbSearchQueryReq, RpbSearchQueryResp, RpbSetBucketReq, RpbSetBucketTypeReq, RpbSetClientIdReq, RpbYokozunaIndex, RpbYokozunaIndexDeleteReq, RpbYokozunaIndexGetReq, RpbYokozunaIndexGetResp, RpbYokozunaIndexPutReq, RpbYokozunaSchema, RpbYokozunaSchemaGetReq, RpbYokozunaSchemaGetResp, RpbYokozunaSchemaPutReq, SetOp, TimeSeriesDeleteOperator, TimeSeriesGetOperator, TimeSeriesListOperator, TimeSeriesPutOperator, TimeSeriesQueryOperator, TsCell, TsCellCodec, TsColumnDescription, TsCoverageEntry, TsCoverageReq, TsCoverageResp, TsDelReq, TsDelResp, TsGetReq, TsGetResp, TsInterpolation, TsListKeysReq, TsListKeysResp, TsPutReq, TsPutResp, TsQueryReq, TsQueryResp, TsRange, TsRow
Constant Summary
ObjectMethods::ENCODING
ProtobuffsBackend::MESSAGE_CODES, ProtobuffsBackend::QUORUMS, ProtobuffsBackend::UINTMAX
FeatureDetection::VERSION
Instance Attribute Summary
#client, #node
Class Method Summary
collapse
Instance Method Summary
collapse
-
#beefcake ⇒ Object
Generated from riak_ts.proto.
-
#bucket_properties_operator ⇒ Object
-
#crdt_loader ⇒ Object
private
Returns a new CrdtLoader for deserializing a protobuffs response full of CRDTs.
-
#crdt_operator ⇒ Object
private
Returns a new CrdtOperator for serializing CRDT operations into protobuffs and sending them to a Riak cluster.
-
#create_search_index(name, schema = nil, n_val = nil, timeout = nil) ⇒ Object
-
#create_search_schema(name, content) ⇒ Object
-
#delete_object(bucket, key, options = {}) ⇒ Object
-
#delete_search_index(name) ⇒ Object
-
#fetch_object(bucket, key, options = {}) ⇒ Object
-
#get_bucket_props(bucket, options = { }) ⇒ Object
-
#get_bucket_type_props(bucket_type) ⇒ Object
-
#get_client_id ⇒ Object
-
#get_counter(bucket, key, options = {}) ⇒ Object
-
#get_index(bucket, index, query, query_options = {}, &block) ⇒ Object
-
#get_preflist(bucket, key, type = nil, options = {}) ⇒ Object
-
#get_search_index(name) ⇒ Object
-
#get_search_schema(name) ⇒ Object
-
#list_buckets(options = {}, &blk) ⇒ Object
override the simple list_buckets.
-
#list_keys(bucket, options = {}, &block) ⇒ Object
-
#mapred(mr, &block) ⇒ Object
-
#new_socket ⇒ Object
-
#ping ⇒ Object
-
#post_counter(bucket, key, amount, options = {}) ⇒ Object
-
#protocol ⇒ Object
-
#reload_object(robject, options = {}) ⇒ Object
-
#reset_bucket_props(bucket, options) ⇒ Object
-
#search(index, query, options = {}) ⇒ Object
-
#server_info ⇒ Object
-
#set_bucket_props(bucket, props, type = nil) ⇒ Object
-
#set_client_id(id) ⇒ Object
-
#store_object(robject, options = {}) ⇒ Object
-
#time_series_delete_operator ⇒ Object
-
#time_series_get_operator(convert_timestamp) ⇒ Object
-
#time_series_list_operator(convert_timestamp) ⇒ Object
-
#time_series_put_operator ⇒ Object
-
#time_series_query_operator(convert_timestamp) ⇒ Object
-
#write_protobuff(code, message) ⇒ Object
#dump_object, #load_object
#initialize, simple, #socket, #teardown
#get_server_version, #http_props_clearable?, #index_pagination?, #index_return_terms?, #index_streaming?, #key_object_bucket_timeouts?, #mapred_phaseless?, #pb_conditionals?, #pb_head?, #pb_indexes?, #pb_search?, #quorum_controls?, #server_version, #tombstone_vclocks?
#escape, #maybe_escape, #maybe_unescape, #unescape
#i18n_scope, #t
Class Method Details
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 24
def self.configured?
begin
require 'beefcake'
require 'riak/client/beefcake/messages'
require 'riak/client/beefcake/message_overlay'
require 'riak/client/beefcake/object_methods'
require 'riak/client/beefcake/bucket_properties_operator'
require 'riak/client/beefcake/crdt_operator'
require 'riak/client/beefcake/crdt_loader'
require 'riak/client/beefcake/time_series_delete_operator'
require 'riak/client/beefcake/time_series_get_operator'
require 'riak/client/beefcake/time_series_list_operator'
require 'riak/client/beefcake/time_series_put_operator'
require 'riak/client/beefcake/time_series_query_operator'
require 'riak/client/beefcake/protocol'
require 'riak/client/beefcake/socket'
true
rescue LoadError, NameError => e
false
end
end
|
Instance Method Details
Generated from riak_ts.proto
22
|
# File 'lib/riak/client/beefcake/messages.rb', line 22
require "beefcake"
|
#bucket_properties_operator ⇒ Object
16
17
18
|
# File 'lib/riak/client/beefcake/bucket_properties_operator.rb', line 16
def bucket_properties_operator
BucketPropertiesOperator.new(self)
end
|
#crdt_loader ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new CrdtLoader for deserializing a protobuffs response full of CRDTs.
28
29
30
|
# File 'lib/riak/client/beefcake/crdt_loader.rb', line 28
def crdt_loader
return CrdtLoader.new self
end
|
#crdt_operator ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new CrdtOperator for serializing CRDT operations into protobuffs and sending them to a Riak cluster.
24
25
26
|
# File 'lib/riak/client/beefcake/crdt_operator.rb', line 24
def crdt_operator
return CrdtOperator.new self
end
|
#create_search_index(name, schema = nil, n_val = nil, timeout = nil) ⇒ Object
403
404
405
406
407
408
409
410
411
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 403
def create_search_index(name, schema = nil, n_val = nil, timeout = nil)
index = RpbYokozunaIndex.new(name: name, schema: schema, n_val: n_val)
req = RpbYokozunaIndexPutReq.new(index: index, timeout: timeout)
protocol do |p|
p.write :YokozunaIndexPutReq, req
p.expect :PutResp
end
end
|
#create_search_schema(name, content) ⇒ Object
440
441
442
443
444
445
446
447
448
449
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 440
def create_search_schema(name, content)
schema = RpbYokozunaSchema.new(:name => name, :content => content)
req = RpbYokozunaSchemaPutReq.new(:schema => schema)
protocol do |p|
p.write :YokozunaSchemaPutReq, req
p.expect :PutResp
end
true
end
|
#delete_object(bucket, key, options = {}) ⇒ Object
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 176
def delete_object(bucket, key, options = {})
if bucket.is_a? Bucket
options[:type] = bucket.type.name if bucket.needs_type?
bucket = bucket.name
end
options = normalize_quorums(options)
options[:bucket] = maybe_encode(bucket)
options[:key] = maybe_encode(key)
options[:vclock] = Base64.decode64(options[:vclock]) if options[:vclock]
req = RpbDelReq.new(prune_unsupported_options(:DelReq, options))
protocol do |p|
p.write :DelReq, req
p.expect :DelResp
end
return true
end
|
#delete_search_index(name) ⇒ Object
431
432
433
434
435
436
437
438
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 431
def delete_search_index(name)
req = RpbYokozunaIndexDeleteReq.new(:name => name)
protocol do |p|
p.write :YokozunaIndexDeleteReq, req
p.expect :DelResp
end
true
end
|
#fetch_object(bucket, key, options = {}) ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 112
def fetch_object(bucket, key, options = {})
options = prune_unsupported_options(:GetReq, normalize_quorums(options))
bucket = Bucket === bucket ? bucket.name : bucket
req = RpbGetReq.new(options.merge(:bucket => maybe_encode(bucket), :key => maybe_encode(key)))
resp = protocol do |p|
p.write :GetReq, req
p.expect :GetResp, RpbGetResp, empty_body_acceptable: true
end
if :empty == resp
raise Riak::ProtobuffsFailedRequest.new(:not_found, t('not_found'))
end
template = RObject.new(client.bucket(bucket), key)
load_object(resp, template)
end
|
#get_bucket_props(bucket, options = { }) ⇒ Object
259
260
261
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 259
def get_bucket_props(bucket, options = { })
bucket_properties_operator.get bucket, options
end
|
#get_bucket_type_props(bucket_type) ⇒ Object
278
279
280
281
282
283
284
285
286
287
288
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 278
def get_bucket_type_props(bucket_type)
bucket_type = bucket_type.name if bucket_type.is_a? BucketType
req = RpbGetBucketTypeReq.new type: bucket_type
resp = protocol do |p|
p.write :GetBucketTypeReq, req
p.expect(:GetBucketResp, RpbGetBucketResp)
end
resp.props.to_hash
end
|
#get_client_id ⇒ Object
81
82
83
84
85
86
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 81
def get_client_id
protocol do |p|
p.write :GetClientIdReq
p.expect(:GetClientIdResp, RpbGetClientIdResp).client_id
end
end
|
#get_counter(bucket, key, options = {}) ⇒ Object
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 216
def get_counter(bucket, key, options = {})
bucket = bucket.name if bucket.is_a? Bucket
options = normalize_quorums(options)
options[:bucket] = bucket
options[:key] = key
request = RpbCounterGetReq.new options
resp = protocol do |p|
p.write :CounterGetReq, request
p.expect :CounterGetResp, RpbCounterGetResp, empty_body_acceptable: true
end
if :empty == resp
return 0
end
return resp.value || 0
end
|
#get_index(bucket, index, query, query_options = {}, &block) ⇒ Object
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 356
def get_index(bucket, index, query, query_options = {}, &block)
return super unless pb_indexes?
bucket = bucket.name if Bucket === bucket
options = if Range === query
{
:qtype => RpbIndexReq::IndexQueryType::RANGE,
:range_min => query.begin.to_s,
:range_max => query.end.to_s
}
else
{
:qtype => RpbIndexReq::IndexQueryType::EQ,
:key => query.to_s
}
end
options.merge!(:bucket => bucket, :index => index.to_s)
options.merge!(query_options)
options[:stream] = block_given?
req = RpbIndexReq.new(options)
protocol do |p|
p.write :IndexReq, req
decode_index_response(p, &block)
end
end
|
#get_preflist(bucket, key, type = nil, options = {}) ⇒ Object
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 195
def get_preflist(bucket, key, type = nil, options = {})
if type.nil? && bucket.is_a?(Riak::BucketTyped::Bucket)
type = bucket.type.name
end
bucket = bucket.name if bucket.is_a? Bucket
type = type.name if type.is_a? BucketType
message = RpbGetBucketKeyPreflistReq.new(
bucket: bucket,
key: key,
type: type
)
resp = protocol do |p|
p.write :GetBucketKeyPreflistReq, message
p.expect :GetBucketKeyPreflistResp, RpbGetBucketKeyPreflistResp
end
resp.preflist
end
|
#get_search_index(name) ⇒ Object
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 413
def get_search_index(name)
req = RpbYokozunaIndexGetReq.new(:name => name)
begin
resp = protocol do |p|
p.write :YokozunaIndexGetReq, req
p.expect :YokozunaIndexGetResp, RpbYokozunaIndexGetResp, empty_body_acceptable: true
end
rescue ProtobuffsErrorResponse => e
if e.code == 0 && e.original_message =~ /notfound/
raise Riak::ProtobuffsFailedRequest.new(:not_found, t('not_found'))
end
raise e
end
resp
end
|
#get_search_schema(name) ⇒ Object
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 451
def get_search_schema(name)
req = RpbYokozunaSchemaGetReq.new(:name => name)
begin
resp = protocol do |p|
p.write :YokozunaSchemaGetReq, req
p.expect :YokozunaSchemaGetResp, RpbYokozunaSchemaGetResp
end
rescue ProtobuffsErrorResponse => e
if e.code == 0 && e.original_message =~ /notfound/
raise Riak::ProtobuffsFailedRequest.new(:not_found, t('not_found'))
end
raise e
end
resp.schema ? resp.schema : resp
end
|
#list_buckets(options = {}, &blk) ⇒ Object
override the simple list_buckets
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 315
def list_buckets(options = {}, &blk)
if block_given?
return streaming_list_buckets options, &blk
end
raise t("streaming_bucket_list_without_block") if options[:stream]
request = RpbListBucketsReq.new options
resp = protocol do |p|
p.write :ListBucketsReq, request
p.expect :ListBucketsResp, RpbListBucketsResp, empty_body_acceptable: true
end
return [] if :empty == resp
resp.buckets
end
|
#list_keys(bucket, options = {}, &block) ⇒ Object
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 290
def list_keys(bucket, options = {}, &block)
bucket = bucket.name if Bucket === bucket
req = RpbListKeysReq.new(options.merge(:bucket => maybe_encode(bucket)))
keys = []
protocol do |p|
p.write :ListKeysReq, req
while msg = p.expect(:ListKeysResp, RpbListKeysResp)
break if msg.done
if block_given?
yield msg.keys
else
keys += msg.keys
end
end
end
return keys unless block_given?
return true
end
|
#mapred(mr, &block) ⇒ Object
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 335
def mapred(mr, &block)
raise MapReduceError.new(t("empty_map_reduce_query")) if mr.query.empty? && !mapred_phaseless?
req = RpbMapRedReq.new(:request => mr.to_json, :content_type => "application/json")
results = MapReduce::Results.new(mr)
protocol do |p|
p.write :MapRedReq, req
while msg = p.expect(:MapRedResp, RpbMapRedResp)
break if msg.done
if block_given?
yield msg.phase, JSON.parse(msg.response)
else
results.add msg.phase, JSON.parse(msg.response)
end
end
end
block_given? || results.report
end
|
#new_socket ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 65
def new_socket
BeefcakeSocket.new(
@node.host,
@node.pb_port,
authentication: client.authentication,
connect_timeout: client.connect_timeout
)
end
|
74
75
76
77
78
79
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 74
def ping
protocol do |p|
p.write :PingReq
p.expect :PingResp
end
end
|
#post_counter(bucket, key, amount, options = {}) ⇒ Object
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 237
def post_counter(bucket, key, amount, options = {})
bucket = bucket.name if bucket.is_a? Bucket
options = normalize_quorums(options)
options[:bucket] = bucket
options[:key] = key
options[:amount] = amount
options[:returnvalue] = options[:returnvalue] || options[:return_value]
request = RpbCounterUpdateReq.new options
resp = protocol do |p|
p.write :CounterUpdateReq, request
p.expect :CounterUpdateResp, RpbCounterUpdateResp, empty_body_acceptable: true
end
return nil if :empty == resp
return resp.value
end
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 47
def protocol
p = Protocol.new(
socket,
read_timeout: client.read_timeout,
write_timeout: client.write_timeout
)
in_request = false
result = nil
begin
in_request = true
result = yield p
in_request = false
ensure
reset_socket if in_request
end
return result
end
|
#reload_object(robject, options = {}) ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 130
def reload_object(robject, options = {})
options = normalize_quorums(options)
options[:bucket] = maybe_encode(robject.bucket.name)
options[:type] = maybe_encode(robject.bucket.type.name) if robject.bucket.needs_type?
options[:key] = maybe_encode(robject.key)
options[:if_modified] = maybe_encode Base64.decode64(robject.vclock) if robject.vclock
req = RpbGetReq.new(prune_unsupported_options(:GetReq, options))
resp = protocol do |p|
p.write :GetReq, req
p.expect :GetResp, RpbGetResp, empty_body_acceptable: true
end
if :empty == resp
raise Riak::ProtobuffsFailedRequest.new(:not_found, t('not_found'))
end
load_object(resp, robject)
end
|
#reset_bucket_props(bucket, options) ⇒ Object
267
268
269
270
271
272
273
274
275
276
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 267
def reset_bucket_props(bucket, options)
bucket = bucket.name if Bucket === bucket
req = RpbResetBucketReq.new(bucket: maybe_encode(bucket),
type: options[:type])
protocol do |p|
p.write :ResetBucketReq, req
p.expect :ResetBucketResp
end
end
|
#search(index, query, options = {}) ⇒ Object
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 384
def search(index, query, options = {})
return super unless pb_search?
options = options.symbolize_keys
options[:op] = options.delete(:'q.op') if options[:'q.op']
req = RpbSearchQueryReq.new(options.merge(:index => index || 'search', :q => query))
resp = protocol do |p|
p.write :SearchQueryReq, req
p.expect :SearchQueryResp, RpbSearchQueryResp
end
resp.docs = [] if resp.docs.nil?
ret = { 'max_score' => resp.max_score, 'num_found' => resp.num_found }
ret['docs'] = resp.docs.map { |d| decode_doc d }
return ret
end
|
#server_info ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 88
def server_info
resp = protocol do |p|
p.write :GetServerInfoReq
p.expect(:GetServerInfoResp, RpbGetServerInfoResp)
end
{ node: resp.node, server_version: resp.server_version }
end
|
#set_bucket_props(bucket, props, type = nil) ⇒ Object
263
264
265
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 263
def set_bucket_props(bucket, props, type = nil)
bucket_properties_operator.put bucket, props, type: type
end
|
#set_client_id(id) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 97
def set_client_id(id)
value = case id
when Integer
[id].pack("N")
else
id.to_s
end
req = RpbSetClientIdReq.new(:client_id => value)
protocol do |p|
p.write :SetClientIdReq, req
p.expect :SetClientIdResp
end
return true
end
|
#store_object(robject, options = {}) ⇒ Object
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 150
def store_object(robject, options = {})
options[:return_body] ||= options[:returnbody]
options = normalize_quorums(options)
if robject.prevent_stale_writes
unless pb_conditionals?
other = fetch_object(robject.bucket, robject.key)
raise Riak::ProtobuffsFailedRequest.new(:stale_object, t("stale_write_prevented")) unless other.vclock == robject.vclock
end
if robject.vclock
options[:if_not_modified] = true
else
options[:if_none_match] = true
end
end
req = dump_object(robject, prune_unsupported_options(:PutReq, options))
resp = protocol do |p|
p.write(:PutReq, req)
p.expect :PutResp, RpbPutResp, empty_body_acceptable: true
end
return true if :empty == resp
load_object resp, robject
end
|
#time_series_delete_operator ⇒ Object
19
20
21
|
# File 'lib/riak/client/beefcake/time_series_delete_operator.rb', line 19
def time_series_delete_operator
TimeSeriesDeleteOperator.new(self)
end
|
#time_series_get_operator(convert_timestamp) ⇒ Object
19
20
21
|
# File 'lib/riak/client/beefcake/time_series_get_operator.rb', line 19
def time_series_get_operator(convert_timestamp)
TimeSeriesGetOperator.new(self, convert_timestamp)
end
|
#time_series_list_operator(convert_timestamp) ⇒ Object
19
20
21
|
# File 'lib/riak/client/beefcake/time_series_list_operator.rb', line 19
def time_series_list_operator(convert_timestamp)
TimeSeriesListOperator.new(self, convert_timestamp)
end
|
#time_series_put_operator ⇒ Object
19
20
21
|
# File 'lib/riak/client/beefcake/time_series_put_operator.rb', line 19
def time_series_put_operator
TimeSeriesPutOperator.new(self)
end
|
#time_series_query_operator(convert_timestamp) ⇒ Object
19
20
21
|
# File 'lib/riak/client/beefcake/time_series_query_operator.rb', line 19
def time_series_query_operator(convert_timestamp)
TimeSeriesQueryOperator.new(self, convert_timestamp)
end
|
#write_protobuff(code, message) ⇒ Object
470
471
472
473
474
|
# File 'lib/riak/client/beefcake_protobuffs_backend.rb', line 470
def write_protobuff(code, message)
encoded = message.encode
= [encoded.length+1, MESSAGE_CODES.index(code)].pack("NC")
socket.write( + encoded)
end
|