Class: VertxConfig::ConfigRetriever

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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)


96
97
98
99
100
101
102
103
104
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-config/config_retriever.rb', line 96

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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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