Class: Etcdv3::Namespace::KV::Transaction

Inherits:
Object
  • Object
show all
Includes:
Requests, Utilities
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb

Constant Summary collapse

COMPARISON_IDENTIFIERS =

Available comparison identifiers.

{
  equal: 0,
  greater: 1,
  less: 2,
  not_equal: 3
}
TARGETS =

Available targets to compare with.

{
  version: 0,
  create_revision: 1,
  mod_revision: 2,
  value: 3
}

Constants included from Requests

Requests::SORT_ORDER, Requests::SORT_TARGET

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Requests

#del_request, #get_request, #put_request

Methods included from Utilities

#delete_prefix, #prepend_prefix, #strip_prefix, #strip_prefix_from_events, #strip_prefix_from_lock

Constructor Details

#initialize(namespace) ⇒ Transaction

Returns a new instance of Transaction.



24
25
26
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 24

def initialize(namespace)
  @namespace = namespace
end

Instance Attribute Details

#compareObject



28
29
30
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 28

def compare
  @compare ||= []
end

#failureObject



36
37
38
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 36

def failure
  @failure ||=[]
end

#successObject



32
33
34
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 32

def success
  @success ||= []
end

Instance Method Details

#create_revision(key, compare_type, value) ⇒ Object

txn.create_revision(‘names’, :less, 10)



75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 75

def create_revision(key, compare_type, value)
  generate_compare(:create_revision, key, compare_type, value)
end

#del(key, range_end = '') ⇒ Object

txn.del(‘key’)



53
54
55
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 53

def del(key, range_end='')
  del_request(key, range_end)
end

#get(key, opts = {}) ⇒ Object

txn.get(‘key’)



48
49
50
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 48

def get(key, opts={})
  get_request(key, opts)
end

#mod_revision(key, compare_type, value) ⇒ Object

txn.mod_revision(‘names’, :not_equal, 0)



70
71
72
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 70

def mod_revision(key, compare_type, value)
  generate_compare(:mod_revision, key, compare_type, value)
end

#put(key, value, lease = nil) ⇒ Object

txn.put(‘my’, ‘key’, lease_id: 1)



43
44
45
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 43

def put(key, value, lease=nil)
  put_request(key, value, lease)
end

#value(key, compare_type, value) ⇒ Object

txn.value(‘names’, :equal, ‘wowza’ )



65
66
67
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 65

def value(key, compare_type, value)
  generate_compare(:value, key, compare_type, value)
end

#version(key, compare_type, value) ⇒ Object

txn.version(‘names’, :greater, 0 )



60
61
62
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/kv/transaction.rb', line 60

def version(key, compare_type, value)
  generate_compare(:version, key, compare_type, value)
end