Class: VertxConsul::Watch
- Inherits:
-
Object
- Object
- VertxConsul::Watch
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb
Overview
Watches are a way of specifying a view of data (e.g. list of nodes, KV pairs, health checks)
which is monitored for updates. When an update is detected, an
Handler
with WatchResult
is invoked.
All errors, except java.util.concurrent.TimeoutException
, will be handled, with resubscribing with a progressive delay.
All timeout errors will be ignored, with resubscribing without any delay.
As an example, you could watch the status of health checks and notify when a check is critical.
Class Method Summary (collapse)
-
+ (::VertxConsul::Watch) events(event = nil, vertx = nil, options = nil)
Creates Watch to monitoring the custom user events.
-
+ (::VertxConsul::Watch) key(key = nil, vertx = nil, options = nil)
Creates Watch to monitoring a specific key in the KV store.
-
+ (::VertxConsul::Watch) key_prefix(keyPrefix = nil, vertx = nil, options = nil)
Creates Watch to monitoring a prefix of keys in the KV store.
-
+ (::VertxConsul::Watch) nodes(vertx = nil, options = nil)
Creates Watch to monitoring the list of available nodes.
-
+ (::VertxConsul::Watch) service(service = nil, vertx = nil, options = nil)
Creates Watch to monitoring the nodes providing the service.
-
+ (::VertxConsul::Watch) services(vertx = nil, options = nil)
Creates Watch to monitoring the list of available services.
Instance Method Summary (collapse)
-
- (self) set_handler { ... }
Set the result handler.
-
- (self) start
Start this Watch.
-
- (void) stop
Stop the watch and release its resources.
Class Method Details
+ (::VertxConsul::Watch) events(event = nil, vertx = nil, options = nil)
Creates
Watch
to monitoring the custom user events.
This maps to the /v1/event/list API internally.
85 86 87 88 89 90 91 92 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 85 def self.events(event=nil,vertx=nil,=nil) if event.class == String && vertx.class.method_defined?(:j_del) && !block_given? && == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:events, [Java::java.lang.String.java_class,Java::IoVertxCore::Vertx.java_class]).call(event,vertx.j_del),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::EventList)) elsif event.class == String && vertx.class.method_defined?(:j_del) && .class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:events, [Java::java.lang.String.java_class,Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtConsul::ConsulClientOptions.java_class]).call(event,vertx.j_del,Java::IoVertxExtConsul::ConsulClientOptions.new(::Vertx::Util::Utils.to_json_object())),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::EventList)) end raise ArgumentError, "Invalid arguments when calling events(#{event},#{vertx},#{})" end |
+ (::VertxConsul::Watch) key(key = nil, vertx = nil, options = nil)
Creates
Watch
to monitoring a specific key in the KV store.
This maps to the /v1/kv/ API internally.
29 30 31 32 33 34 35 36 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 29 def self.key(key=nil,vertx=nil,=nil) if key.class == String && vertx.class.method_defined?(:j_del) && !block_given? && == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:key, [Java::java.lang.String.java_class,Java::IoVertxCore::Vertx.java_class]).call(key,vertx.j_del),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::KeyValue)) elsif key.class == String && vertx.class.method_defined?(:j_del) && .class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:key, [Java::java.lang.String.java_class,Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtConsul::ConsulClientOptions.java_class]).call(key,vertx.j_del,Java::IoVertxExtConsul::ConsulClientOptions.new(::Vertx::Util::Utils.to_json_object())),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::KeyValue)) end raise ArgumentError, "Invalid arguments when calling key(#{key},#{vertx},#{})" end |
+ (::VertxConsul::Watch) key_prefix(keyPrefix = nil, vertx = nil, options = nil)
Creates
Watch
to monitoring a prefix of keys in the KV store.
This maps to the /v1/kv/ API internally.
43 44 45 46 47 48 49 50 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 43 def self.key_prefix(keyPrefix=nil,vertx=nil,=nil) if keyPrefix.class == String && vertx.class.method_defined?(:j_del) && !block_given? && == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:keyPrefix, [Java::java.lang.String.java_class,Java::IoVertxCore::Vertx.java_class]).call(keyPrefix,vertx.j_del),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::KeyValueList)) elsif keyPrefix.class == String && vertx.class.method_defined?(:j_del) && .class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:keyPrefix, [Java::java.lang.String.java_class,Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtConsul::ConsulClientOptions.java_class]).call(keyPrefix,vertx.j_del,Java::IoVertxExtConsul::ConsulClientOptions.new(::Vertx::Util::Utils.to_json_object())),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::KeyValueList)) end raise ArgumentError, "Invalid arguments when calling key_prefix(#{keyPrefix},#{vertx},#{})" end |
+ (::VertxConsul::Watch) nodes(vertx = nil, options = nil)
Creates
Watch
to monitoring the list of available nodes.
This maps to the /v1/catalog/nodes API internally.
98 99 100 101 102 103 104 105 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 98 def self.nodes(vertx=nil,=nil) if vertx.class.method_defined?(:j_del) && !block_given? && == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:nodes, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::NodeList)) elsif vertx.class.method_defined?(:j_del) && .class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:nodes, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtConsul::ConsulClientOptions.java_class]).call(vertx.j_del,Java::IoVertxExtConsul::ConsulClientOptions.new(::Vertx::Util::Utils.to_json_object())),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::NodeList)) end raise ArgumentError, "Invalid arguments when calling nodes(#{vertx},#{})" end |
+ (::VertxConsul::Watch) service(service = nil, vertx = nil, options = nil)
Creates
Watch
to monitoring the nodes providing the service.
Nodes will be sorted by distance from the consul agent.
This maps to the /v1/health/service/<service> API internally.
71 72 73 74 75 76 77 78 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 71 def self.service(service=nil,vertx=nil,=nil) if service.class == String && vertx.class.method_defined?(:j_del) && !block_given? && == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:service, [Java::java.lang.String.java_class,Java::IoVertxCore::Vertx.java_class]).call(service,vertx.j_del),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::ServiceEntryList)) elsif service.class == String && vertx.class.method_defined?(:j_del) && .class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:service, [Java::java.lang.String.java_class,Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtConsul::ConsulClientOptions.java_class]).call(service,vertx.j_del,Java::IoVertxExtConsul::ConsulClientOptions.new(::Vertx::Util::Utils.to_json_object())),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::ServiceEntryList)) end raise ArgumentError, "Invalid arguments when calling service(#{service},#{vertx},#{})" end |
+ (::VertxConsul::Watch) services(vertx = nil, options = nil)
Creates
Watch
to monitoring the list of available services.
This maps to the /v1/catalog/services API internally.
56 57 58 59 60 61 62 63 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 56 def self.services(vertx=nil,=nil) if vertx.class.method_defined?(:j_del) && !block_given? && == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:services, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::ServiceList)) elsif vertx.class.method_defined?(:j_del) && .class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtConsul::Watch.java_method(:services, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtConsul::ConsulClientOptions.java_class]).call(vertx.j_del,Java::IoVertxExtConsul::ConsulClientOptions.new(::Vertx::Util::Utils.to_json_object())),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::ServiceList)) end raise ArgumentError, "Invalid arguments when calling services(#{vertx},#{})" end |
Instance Method Details
- (self) set_handler { ... }
Set the result handler. As data is changed, the handler will be called with the result.
109 110 111 112 113 114 115 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 109 def set_handler if block_given? @j_del.java_method(:setHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxConsul::WatchResult, nil)) })) return self end raise ArgumentError, "Invalid arguments when calling set_handler()" end |
- (self) start
Start this
Watch
118 119 120 121 122 123 124 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 118 def start if !block_given? @j_del.java_method(:start, []).call() return self end raise ArgumentError, "Invalid arguments when calling start()" end |
- (void) stop
This method returns an undefined value.
Stop the watch and release its resources
127 128 129 130 131 132 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 127 def stop if !block_given? return @j_del.java_method(:stop, []).call() end raise ArgumentError, "Invalid arguments when calling stop()" end |