vert-x3 / vertx-config

Vert.x Configuration Service
Apache License 2.0
54 stars 64 forks source link

Documentation shows how to read configuration, doesn't show what to do with it #22

Closed dmolesUC closed 6 years ago

dmolesUC commented 7 years ago

The documentation page does an excellent job of explaining how to read different types of configurations, but it's not at all clear what to do once you've called retriever.getConfig().

The only example I could find on line was this StackOverflow question, which hard-codes everything (ConfigStoreOptions, ConfigRetrieverOptions, ConfigRetriever) into one verticle's start() method and then constructs DeploymentOptions for a second verticle.

I've literally only been working with Vert.x for a day, so maybe this is more sensible than it sounds, but starting an extra verticle just to read the configuration seems like overkill to me. Alternatively, I could put ConfigRetriever.create() etc. directly in the start() method of my main verticle, call getConfig() there, and make use of the result directly; but this ignores AbstractVerticle.config() (i.e., the config coming from Context), which seems likely to lead to confusion and errors down the road.

It seems like there should be a way to inject the retrieved config into the context, but it's not at all clear what that would be. (Possibly something involving subclassing the Launcher?)

jaguililla commented 6 years ago

I think you can call create on start and hold a reference in your Verticle instance. Once loaded you probably can use cachedConfig for everything else. I guess this take care of previous settings loaded in Verticle configuration (config()).

If this is ok you can close the issue ;)

dmolesUC commented 6 years ago

I’m afraid that’s still not clear to me -- neither exactly what I should do, nor why it would work. Is it too much to ask that the documentation show how to use the retrieved configuration?

jaguililla commented 6 years ago

Sorry, I'm afraid I can not help you with that :(