Class: VertxConfig::ConfigRetriever

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb

Overview

Defines a configuration retriever that read configuration from and tracks changes periodically.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 23

def @@j_api_type.accept?(obj)
  obj.class == ConfigRetriever
end

+ (::VertxConfig::ConfigRetriever) create(vertx) + (::VertxConfig::ConfigRetriever) create(vertx, options)

Creates an instance of the default implementation of the VertxConfig::ConfigRetriever.

Overloads:

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 73

def self.create(*args)
  if args[0].class.method_defined?(:j_del) && !block_given? && args[1] == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxConfig::ConfigRetriever.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(args[0].j_del),::VertxConfig::ConfigRetriever)
  elsif args[0].class.method_defined?(:j_del) && args[1].class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxConfig::ConfigRetriever.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxConfig::ConfigRetrieverOptions.java_class]).call(args[0].j_del,Java::IoVertxConfig::ConfigRetrieverOptions.new(::Vertx::Util::Utils.to_json_object(args[1]))),::VertxConfig::ConfigRetriever)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling create(#{args[0]},#{args[1]})"
  end
end

+ (Object) j_api_type



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 32

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 35

def self.j_class
  Java::IoVertxConfig::ConfigRetriever.java_class
end

+ (Object) unwrap(obj)



29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 29

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 26

def @@j_api_type.wrap(obj)
  ConfigRetriever.new(obj)
end

Instance Method Details

- (void) close

This method returns an undefined value.

Closes the retriever.


104
105
106
107
108
109
110
111
112
113
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 104

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

- (::Vertx::ReadStream) configStream

Returns the stream of configurations. It's single stream (unicast) and that delivers the last known config and the successors periodically.

Returns:

  • (::Vertx::ReadStream)
    the stream of configurations. It's single stream (unicast) and that delivers the last known config and the successors periodically.


53
54
55
56
57
58
59
60
61
62
63
64
65
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 53

def config_stream
  if !block_given?
    if @cached_config_stream != nil
      return @cached_config_stream
    end
    return @cached_config_stream = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:configStream, []).call(),::Vertx::ReadStreamImpl, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling config_stream()"
  end
end

- (Hash{String => Object}) getCachedConfig

Gets the last computed configuration.

Returns:

  • (Hash{String => Object})
    the last configuration


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

def get_cached_config
  if !block_given?
    return @j_del.java_method(:getCachedConfig, []).call() != nil ? JSON.parse(@j_del.java_method(:getCachedConfig, []).call().encode) : nil
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_cached_config()"
  end
end

- (void) getConfig(completionHandler) { ... }

This method returns an undefined value.

Reads the configuration from the different and computes the final configuration.

Yields:

  • handler receiving the computed configuration, or a failure if the configuration cannot be retrieved


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 134

def get_config
  if true
    if (block_given?)
      return @j_del.java_method(:getConfig, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
    else
      promise = ::Vertx::Util::Utils.promise
      @j_del.java_method(:getConfig, [Java::IoVertxCore::Handler.java_class]).call(block_given? ? Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) } : promise)
      return ::Vertx::Util::Utils.safe_create(promise.future(),::Vertx::Future, nil)
    end
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_config()"
  end
end

- (void) listen(listener) { ... }

This method returns an undefined value.

Registers a listener receiving configuration changes. This method cannot only be called if the configuration is broadcasted.

Yields:

  • the listener


119
120
121
122
123
124
125
126
127
128
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 119

def listen
  if true
    return @j_del.java_method(:listen, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.toJson.encode) : nil) unless !block_given? }))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling listen()"
  end
end

- (self) setBeforeScanHandler(handler) { ... }

Registers a handler called before every scan. This method is mostly used for logging purpose.

Yields:

  • the handler, must not be null

Returns:

  • (self)


154
155
156
157
158
159
160
161
162
163
164
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 154

def set_before_scan_handler
  if true
    @j_del.java_method(:setBeforeScanHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(nil) unless !block_given? }))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_before_scan_handler()"
  end
end

- (self) setConfigurationProcessor(processor) { ... }

Registers a handler that process the configuration before being injected into #get_config or #listen. This allows the code to customize the configuration.

Yields:

  • the processor, must not be null. The method must not return null. The returned configuration is used. If the processor does not update the configuration, it must return the input configuration. If the processor throws an exception, the failure is passed to the #get_config handler.

Returns:

  • (self)


90
91
92
93
94
95
96
97
98
99
100
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 90

def set_configuration_processor(*args)
  if block_given? && args[0] == nil
    @j_del.java_method(:setConfigurationProcessor, [Java::JavaUtilFunction::Function.java_class]).call((Proc.new { |event| ::Vertx::Util::Utils.to_json_object(yield(event != nil ? JSON.parse(event.encode) : nil)) unless !block_given? }))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_configuration_processor(#{args[0]})"
  end
end