Class: VertxConfig::ConfigRetriever
- Inherits:
-
Object
- Object
- VertxConfig::ConfigRetriever
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)
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
|
88
89
90
91
92
93
94
95
96
97
98
99
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 88
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
|
+ (::Vertx::Future) getConfigAsFuture(retriever)
Same as
#get_config, but returning a object. The result is a
.
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 56
def self.get_config_as_future(*args)
if args[0].class.method_defined?(:j_del) && !block_given?
return ::Vertx::Util::Utils.safe_create(Java::IoVertxConfig::ConfigRetriever.java_method(:getConfigAsFuture, [Java::IoVertxConfig::ConfigRetriever.java_class]).call(args[0].j_del),::Vertx::Future, nil)
end
if defined?(super)
super
else
raise ArgumentError, "Invalid arguments when calling get_config_as_future(#{args[0]})"
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.
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 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
|
Returns the stream of configurations. It's single stream (unicast) and that delivers the last known config and the successors periodically.
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 68
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.
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.
149
150
151
152
153
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 149
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.
134
135
136
137
138
139
140
141
142
143
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 134
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.
169
170
171
172
173
174
175
176
177
178
179
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 169
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.
105
106
107
108
109
110
111
112
113
114
115
|
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 105
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
|