Class: VertxConsul::Watch

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/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 AsyncResult is invoked. As an example, you could watch the status of health checks and notify when a check is critical.

Class Method Summary (collapse)

Instance Method Summary (collapse)

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.

Parameters:

  • event (String) (defaults to: nil)
    the event name
  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance
  • options (Hash) (defaults to: nil)
    the options to create underlying Consul client

Returns:

Raises:

  • (ArgumentError)


81
82
83
84
85
86
87
88
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 81

def self.events(event=nil,vertx=nil,options=nil)
  if event.class == String && vertx.class.method_defined?(:j_del) && !block_given? && options == 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) && options.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(options))),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::EventList))
  end
  raise ArgumentError, "Invalid arguments when calling events(#{event},#{vertx},#{options})"
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.

Parameters:

  • key (String) (defaults to: nil)
    the key
  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance
  • options (Hash) (defaults to: nil)
    the options to create underlying Consul client

Returns:

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
33
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 26

def self.key(key=nil,vertx=nil,options=nil)
  if key.class == String && vertx.class.method_defined?(:j_del) && !block_given? && options == 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) && options.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(options))),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::KeyValue))
  end
  raise ArgumentError, "Invalid arguments when calling key(#{key},#{vertx},#{options})"
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.

Parameters:

  • keyPrefix (String) (defaults to: nil)
    the key
  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance
  • options (Hash) (defaults to: nil)
    the options to create underlying Consul client

Returns:

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 40

def self.key_prefix(keyPrefix=nil,vertx=nil,options=nil)
  if keyPrefix.class == String && vertx.class.method_defined?(:j_del) && !block_given? && options == 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) && options.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(options))),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::KeyValueList))
  end
  raise ArgumentError, "Invalid arguments when calling key_prefix(#{keyPrefix},#{vertx},#{options})"
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.

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance
  • options (Hash) (defaults to: nil)
    the options to create underlying Consul client

Returns:

Raises:

  • (ArgumentError)


94
95
96
97
98
99
100
101
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 94

def self.nodes(vertx=nil,options=nil)
  if vertx.class.method_defined?(:j_del) && !block_given? && options == 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) && options.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(options))),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::NodeList))
  end
  raise ArgumentError, "Invalid arguments when calling nodes(#{vertx},#{options})"
end

+ (::VertxConsul::Watch) service(service = nil, vertx = nil, options = nil)

Creates Watch to monitoring the nodes providing the service. This maps to the /v1/health/service/<service> API internally.

Parameters:

  • service (String) (defaults to: nil)
    the service name
  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance
  • options (Hash) (defaults to: nil)
    the options to create underlying Consul client

Returns:

Raises:

  • (ArgumentError)


67
68
69
70
71
72
73
74
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 67

def self.service(service=nil,vertx=nil,options=nil)
  if service.class == String && vertx.class.method_defined?(:j_del) && !block_given? && options == 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) && options.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(options))),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::ServiceEntryList))
  end
  raise ArgumentError, "Invalid arguments when calling service(#{service},#{vertx},#{options})"
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.

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance
  • options (Hash) (defaults to: nil)
    the options to create underlying Consul client

Returns:

Raises:

  • (ArgumentError)


53
54
55
56
57
58
59
60
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 53

def self.services(vertx=nil,options=nil)
  if vertx.class.method_defined?(:j_del) && !block_given? && options == 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) && options.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(options))),::VertxConsul::Watch,::Vertx::Util::data_object_type(Java::IoVertxExtConsul::ServiceList))
  end
  raise ArgumentError, "Invalid arguments when calling services(#{vertx},#{options})"
end

Instance Method Details

- (self) set_handler { ... }

Set the result handler. As data is changed, the handler will be called with the result.

Yields:

  • the result handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


105
106
107
108
109
110
111
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 105

def set_handler
  if block_given?
    @j_del.java_method(:setHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? @j_arg_T.wrap(ar.result) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_handler()"
end

- (self) start

Start this Watch

Returns:

  • (self)

Raises:

  • (ArgumentError)


114
115
116
117
118
119
120
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 114

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

Raises:

  • (ArgumentError)


123
124
125
126
127
128
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-consul/watch.rb', line 123

def stop
  if !block_given?
    return @j_del.java_method(:stop, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling stop()"
end