Class: Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator Private
- Includes:
- Util::Translation
- Defined in:
- lib/riak/client/beefcake/crdt_operator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Serializes and writes CRDT operations from Riak::Crdt::Operation members into protobuffs, and writes them to a Riak cluster.
Instance Attribute Summary collapse
- #backend ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(backend) ⇒ CrdtOperator
constructor
private
A new instance of CrdtOperator.
-
#operate(bucket, key, bucket_type, operation, options = {}) ⇒ Object
private
Serializes and writes CRDT operations.
-
#serialize(operations) ⇒ Object
private
Serializes CRDT operations without writing them.
Methods included from Util::Translation
Constructor Details
#initialize(backend) ⇒ CrdtOperator
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 instance of CrdtOperator.
22 23 24 |
# File 'lib/riak/client/beefcake/crdt_operator.rb', line 22 def initialize(backend) @backend = backend end |
Instance Attribute Details
#backend ⇒ Object (readonly)
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.
20 21 22 |
# File 'lib/riak/client/beefcake/crdt_operator.rb', line 20 def backend @backend end |
Instance Method Details
#operate(bucket, key, bucket_type, operation, options = {}) ⇒ 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.
Serializes and writes CRDT operations.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/riak/client/beefcake/crdt_operator.rb', line 27 def operate(bucket, key, bucket_type, operation, = {}) serialized = serialize(operation) args = { bucket: bucket, key: key, type: bucket_type, op: serialized, return_body: true, }.merge request = DtUpdateReq.new args begin return backend.protocol do |p| p.write :DtUpdateReq, request p.expect :DtUpdateResp, DtUpdateResp, empty_body_acceptable: true end rescue ProtobuffsErrorResponse => e raise unless e. =~ /precondition/ raise CrdtError::PreconditionError.new e. end end |
#serialize(operations) ⇒ 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.
Serializes CRDT operations without writing them.
49 50 51 52 53 |
# File 'lib/riak/client/beefcake/crdt_operator.rb', line 49 def serialize(operations) return serialize [operations] unless operations.is_a? Enumerable serialize_wrap operations end |