what is appropriate way to load config with ConfigRetriever to configure Vertx instance with vertxOptions, because ConfigRetriever already need Vertx instance
I know it can be done with system or env variables, but it is ok to get config from json/yaml ... file for that.
Is it ok to create temporary vertx instance to load config and after config load or failure close this temp vertx.:
Future<JsonObject> loadConfig() {
ConfigRetrieverOptions retrieverOptions = new ConfigRetrieverOptions();
addConfigStores(retrieverOptions, "application.yaml");
addConfigStore(retrieverOptions, "some path");
addConfigStore(retrieverOptions, "some path 2");
final Vertx configVertx = Vertx.vertx(); //Creating temporary vertx instance
ConfigRetriever.create(configVertx, retrieverOptions).getConfig()
.onComplete(ar -> {
JsonObject conf = ar.result();
promise.complete(conf);
configVertx.close(); //close config vertx
})
.onFailure(cause -> {
promise.fail(cause);
configVertx.close(); //close config vertx
});
return promise.future();
}
//on config loaded
loadConfig.onSuccess(cong -> {
...
vertxOptions.setTracingOptions(
new ZipkinTracingOptions()
.setServiceName(getConfig(config, "zipkin.service-name"))
.setSenderOptions(new HttpSenderOptions()
.setSenderEndpoint(getConfig(config, "zipkin.endpoint"))
)
);
this.vertx = Vertx.vertx(vertxOptions); //create configured vertx instance
})
.onFailure(t -> ...);