Class: VertxConsul::Watch

Inherits:
Object
  • Object
show all
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 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)


82
83
84
85
86
87
88
89
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 82

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)


27
28
29
30
31
32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 27

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)


41
42
43
44
45
46
47
48
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 41

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)


95
96
97
98
99
100
101
102
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 95

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)


68
69
70
71
72
73
74
75
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 68

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)


54
55
56
57
58
59
60
61
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 54

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)


106
107
108
109
110
111
112
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 106

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

Returns:

  • (self)

Raises:

  • (ArgumentError)


115
116
117
118
119
120
121
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 115

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)


124
125
126
127
128
129
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-consul/watch.rb', line 124

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