Class: Etcdv3::Watch
- Inherits:
-
Object
- Object
- Etcdv3::Watch
- Defined in:
- lib/etcdv3/watch.rb
Instance Method Summary collapse
-
#initialize(hostname, credentials, metadata = {}) ⇒ Watch
constructor
A new instance of Watch.
- #watch(key, range_end, block) ⇒ Object
Constructor Details
#initialize(hostname, credentials, metadata = {}) ⇒ Watch
Returns a new instance of Watch.
4 5 6 7 |
# File 'lib/etcdv3/watch.rb', line 4 def initialize(hostname, credentials, = {}) @stub = Etcdserverpb::Watch::Stub.new(hostname, credentials) = end |
Instance Method Details
#watch(key, range_end, block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/etcdv3/watch.rb', line 9 def watch(key, range_end, block) create_req = Etcdserverpb::WatchCreateRequest.new(key: key, range_end: range_end) watch_req = Etcdserverpb::WatchRequest.new(create_request: create_req) events = nil @stub.watch([watch_req]).each do |resp| next if resp.events.empty? if block block.call(resp.events) else events = resp.events break end end events end |