Class: Etcdv3::KV::Transaction

Inherits:
Object
  • Object
show all
Includes:
Requests
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/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

Constructor Details

#initializeTransaction

Returns a new instance of Transaction.



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

def initialize; end

Instance Attribute Details

#compareObject



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

def compare
  @compare ||= []
end

#failureObject



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

def failure
  @failure ||=[]
end

#successObject



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

def success
  @success ||= []
end

Instance Method Details

#create_revision(key, compare_type, value) ⇒ Object

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



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

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

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

txn.del(‘key’)



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

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

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

txn.get(‘key’)



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

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

#mod_revision(key, compare_type, value) ⇒ Object

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



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

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)



40
41
42
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv/transaction.rb', line 40

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

#value(key, compare_type, value) ⇒ Object

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



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

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 )



57
58
59
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv/transaction.rb', line 57

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