new ConfigRetriever()
Defines a configuration retriever that read configuration from
Methods
close()
Closes the retriever.
configStream() → {ReadStream}
Returns:
the stream of configurations. It's single stream (unicast) and that delivers the last known config and the successors periodically.
- Type
- ReadStream
getCachedConfig() → {Object}
Gets the last computed configuration.
Returns:
the last configuration
- Type
- Object
getConfig(completionHandler)
Reads the configuration from the different
and computes the final configuration.
Parameters:
| Name | Type | Description |
|---|---|---|
completionHandler |
function | handler receiving the computed configuration, or a failure if the configuration cannot be retrieved |
listen(listener)
Registers a listener receiving configuration changes. This method cannot only be called if
the configuration is broadcasted.
Parameters:
| Name | Type | Description |
|---|---|---|
listener |
function | the listener |
setBeforeScanHandler(handler) → {ConfigRetriever}
Registers a handler called before every scan. This method is mostly used for logging purpose.
Parameters:
| Name | Type | Description |
|---|---|---|
handler |
function | the handler, must not be null |
Returns:
the current config retriever
- Type
- ConfigRetriever
setConfigurationProcessor(processor) → {ConfigRetriever}
Registers a handler that process the configuration before being injected into ConfigRetriever#getConfig or ConfigRetriever#listen. This allows
the code to customize the configuration.
Parameters:
| Name | Type | Description |
|---|---|---|
processor |
function | 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 ConfigRetriever#getConfig handler. |
Returns:
the current config retriever
- Type
- ConfigRetriever