RemoteSource
class RemoteSource(initial: Map<String, String> = emptyMap(), val keyFormat: KeyFormat = KeyFormat.DOT_NOTATION, val fallbackKeyFormats: List<KeyFormat> = listOf(KeyFormat.SCREAMING_SNAKE), val name: String = "RemoteSource") : ReloadableSource(source)
A source whose values are pushed in by the app, typically from a remote config service. It works with any provider: fetch the values, then call update. Each change is reported on changes, so ReloadableConfig.watch reloads the config:
val remote = RemoteSource(name = "Firebase")
val appConfig = ReloadableConfig.load(load = { loadAppConfig() }) {
sources {
+remote // first, so remote values override the local defaults
+TomlSource.fromResource("config.toml")
}
}
appConfig.watch(scope, remote)
// Whenever the provider has new values
remote.update(fetchedValues)Content copied to clipboard
Keys use keyFormat (dot notation by default, e.g. server.port) and are matched case-insensitively, like the file sources.
Constructors
Properties
Link copied to clipboard
Emits once when collection starts and again after each update that changed the values, so updates made before ReloadableConfig.watch starts collecting are not missed. Updating to equal values emits nothing.
Link copied to clipboard