Class: Etcdv3::KV
- Inherits:
-
Object
show all
- Includes:
- Requests, GRPC::Core::TimeConsts
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv/requests.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv/transaction.rb
Defined Under Namespace
Modules: Requests
Classes: Transaction
Constant Summary
Constants included
from Requests
Requests::SORT_ORDER, Requests::SORT_TARGET
Instance Method Summary
collapse
-
#del(key, range_end: '', timeout: nil) ⇒ Object
-
#get(key, opts = {}) ⇒ Object
-
#initialize(hostname, credentials, timeout, metadata = {}) ⇒ KV
constructor
-
#put(key, value, lease: nil, timeout: nil) ⇒ Object
-
#transaction(block, timeout: nil) ⇒ Object
from_relative_time
Methods included from Requests
#del_request, #get_request, #put_request
Constructor Details
#initialize(hostname, credentials, timeout, metadata = {}) ⇒ KV
7
8
9
10
11
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv.rb', line 7
def initialize(hostname, credentials, timeout, metadata={})
@stub = Etcdserverpb::KV::Stub.new(hostname, credentials)
@timeout = timeout
@metadata = metadata
end
|
Instance Method Details
#del(key, range_end: '', timeout: nil) ⇒ Object
18
19
20
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv.rb', line 18
def del(key, range_end: '', timeout: nil)
@stub.delete_range(del_request(key, range_end), metadata: @metadata, deadline: deadline(timeout))
end
|
#get(key, opts = {}) ⇒ Object
13
14
15
16
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv.rb', line 13
def get(key, opts={})
timeout = opts.delete(:timeout)
@stub.range(get_request(key, opts), metadata: @metadata, deadline: deadline(timeout))
end
|
#put(key, value, lease: nil, timeout: nil) ⇒ Object
22
23
24
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv.rb', line 22
def put(key, value, lease: nil, timeout: nil)
@stub.put(put_request(key, value, lease), metadata: @metadata, deadline: deadline(timeout))
end
|
#transaction(block, timeout: nil) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/kv.rb', line 26
def transaction(block, timeout: nil)
txn = Etcdv3::KV::Transaction.new
block.call(txn)
request = Etcdserverpb::TxnRequest.new(
compare: txn.compare,
success: generate_request_ops(txn.success),
failure: generate_request_ops(txn.failure)
)
@stub.txn(request, metadata: @metadata, deadline: deadline(timeout))
end
|