Class: Couchbase::Options::Append

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/options.rb

Overview

Constant Summary collapse

DEFAULT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Append.new.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#client_context, #parent_span, #retry_strategy, #timeout

Instance Method Summary collapse

Constructor Details

#initialize(cas: nil, durability_level: :none, replicate_to: :none, persist_to: :none, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Append

Creates an instance of options for BinaryCollection#append

Parameters:

  • cas (Integer) (defaults to: nil)

    The default CAS used (0 means no CAS in this context)

  • durability_level (Symbol) (defaults to: :none)

    level of durability :none::

    no enhanced durability required for the mutation
    

    :majority::

    the mutation must be replicated to a majority of the Data Service nodes
    (that is, held in the memory allocated to the bucket)
    

    :majority_and_persist_to_active::

    The mutation must be replicated to a majority of the Data Service nodes.
    Additionally, it must be persisted (that is, written and synchronised to disk) on the
    node hosting the active partition (vBucket) for the data.
    

    :persist_to_majority::

    The mutation must be persisted to a majority of the Data Service nodes.
    Accordingly, it will be written to disk on those nodes.
  • replicate_to (Symbol) (defaults to: :none)

    number of nodes to replicate :none:: do not apply any replication requirements. :one:: wait for replication to at least one node. :two:: wait for replication to at least two nodes. :three:: wait for replication to at least three nodes.

  • persist_to (Symbol) (defaults to: :none)

    number of nodes to persist :none:: do not apply any persistence requirements. :active:: wait for persistence to active node :one:: wait for persistence to at least one node. :two:: wait for persistence to at least two nodes. :three:: wait for persistence to at least three nodes. :four:: wait for persistence to four nodes (active and replicas).

  • timeout (Integer, #in_milliseconds, nil) (defaults to: nil)
  • retry_strategy (Proc, nil) (defaults to: nil)

    the custom retry strategy, if set

  • client_context (Hash, nil) (defaults to: nil)

    the client context data, if set

  • parent_span (Span, nil) (defaults to: nil)

    if set holds the parent span, that should be used for this request

Yield Parameters:



1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
# File 'lib/couchbase/options.rb', line 1247

def initialize(cas: nil,
               durability_level: :none,
               replicate_to: :none,
               persist_to: :none,
               timeout: nil,
               retry_strategy: nil,
               client_context: nil,
               parent_span: nil)
  super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
  @cas = cas

  if durability_level != :none && (replicate_to != :none || persist_to != :none)
    raise ArgumentError, "durability_level conflicts with replicate_to and persist_to options"
  end

  @durability_level = durability_level
  @replicate_to = replicate_to
  @persist_to = persist_to
  yield self if block_given?
end

Instance Attribute Details

#casInteger

Returns:

  • (Integer)


1207
1208
1209
# File 'lib/couchbase/options.rb', line 1207

def cas
  @cas
end

#durability_levelSymbol

Returns:

  • (Symbol)


1208
1209
1210
# File 'lib/couchbase/options.rb', line 1208

def durability_level
  @durability_level
end

#persist_toSymbol

Returns:

  • (Symbol)


1210
1211
1212
# File 'lib/couchbase/options.rb', line 1210

def persist_to
  @persist_to
end

#replicate_toSymbol

Returns:

  • (Symbol)


1209
1210
1211
# File 'lib/couchbase/options.rb', line 1209

def replicate_to
  @replicate_to
end

Instance Method Details

#to_backendObject

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.



1269
1270
1271
1272
1273
1274
1275
1276
1277
# File 'lib/couchbase/options.rb', line 1269

def to_backend
  {
    timeout: Utils::Time.extract_duration(@timeout),
    cas: @cas,
    durability_level: @durability_level,
    persist_to: @persist_to,
    replicate_to: @replicate_to,
  }
end