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)


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

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

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

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

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the vert.x instance
  • options (Hash) (defaults to: nil)
    the options, must not be null, must contain the list of configured store.

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-config/config_retriever.rb', line 41

def self.create(vertx=nil,options=nil)
  if vertx.class.method_defined?(:j_del) && !block_given? && options == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxConfig::ConfigRetriever.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxConfig::ConfigRetriever)
  elsif vertx.class.method_defined?(:j_del) && options.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(vertx.j_del,Java::IoVertxConfig::ConfigRetrieverOptions.new(::Vertx::Util::Utils.to_json_object(options))),::VertxConfig::ConfigRetriever)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{options})"
end

+ (::Vertx::Future) get_config_as_future(retriever = nil)

Same as #get_config, but returning a object. The result is a .

Parameters:

Returns:

  • (::Vertx::Future)
    the future completed when the configuration is retrieved

Raises:

  • (ArgumentError)


53
54
55
56
57
58
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 53

def self.get_config_as_future(retriever=nil)
  if retriever.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(retriever.j_del),::Vertx::Future, nil)
  end
  raise ArgumentError, "Invalid arguments when calling get_config_as_future(#{retriever})"
end

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

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

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (void) close

This method returns an undefined value.

Closes the retriever.

Raises:

  • (ArgumentError)


71
72
73
74
75
76
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 71

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

- (::Vertx::ReadStream) config_stream

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.

Raises:

  • (ArgumentError)


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

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
  raise ArgumentError, "Invalid arguments when calling config_stream()"
end

- (Hash{String => Object}) get_cached_config

Gets the last computed configuration.

Returns:

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

Raises:

  • (ArgumentError)


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 79

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
  raise ArgumentError, "Invalid arguments when calling get_cached_config()"
end

- (void) get_config { ... }

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

Raises:

  • (ArgumentError)


63
64
65
66
67
68
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 63

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

- (void) listen { ... }

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

Raises:

  • (ArgumentError)


89
90
91
92
93
94
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 89

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

- (self) set_before_scan_handler { ... }

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

Yields:

  • the function, must not be null

Returns:

  • (self)

Raises:

  • (ArgumentError)


98
99
100
101
102
103
104
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-config/config_retriever.rb', line 98

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

- (self) set_configuration_processor(processor = nil) { ... }

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)

Raises:

  • (ArgumentError)


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 109

def set_configuration_processor(processor=nil)
  if block_given? && processor == 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)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_configuration_processor(#{processor})"
end