Repository navigation
docs: Document application configuration - #1174
Conversation
|
|
||
| To access the configuration in application code you can use a constructor parameter `com.typesafe.config.Config` in all components and the `ServiceSetup` class. An example of this is shown in xref:setup-and-dependency-injection.adoc#_disabling_components[]. | ||
|
|
||
| WARNING: Don't use `ConfigFactory.load()` since that will not load the `application.conf` as you intended. Use dependency injection of `Config` instead. |
There was a problem hiding this comment.
here is the warning that was requested in the issue
There was a problem hiding this comment.
I know this was the concrete thing the user hit but I don't like notes about what APIs you shouldn't use, isn't it better with just the right way than to try to cover everything you could do that won't work?
There was a problem hiding this comment.
I agree but seems like it was a strong opinion about that we should highlight this problem. We don't behave as "normal" so I can understand that we should document the wrong way. New users probably don't know about ConfigFactory at all, but AI assistants will use it. I tried in a sample that was setup with right claude instructions and akka-context, and it recommends ConfigFactory.load().
I'm using Akka and need to read the application.conf in my service, how should I do that?
It's also a pretty bad mistake since it will probably work locally, but then fail when deployed.
There was a problem hiding this comment.
Ok, let's leave it in then
There was a problem hiding this comment.
Does this mean that AI coding assistants honor this from now on and behave different, e.g. not recommending ConfigFactory.load()?
There was a problem hiding this comment.
That depends on how well they read the documentation.
There was a problem hiding this comment.
I wonder if there is any way to throw an error/warning if they try....
johanandren
left a comment
There was a problem hiding this comment.
LGTM with one opinion
|
|
||
| To access the configuration in application code you can use a constructor parameter `com.typesafe.config.Config` in all components and the `ServiceSetup` class. An example of this is shown in xref:setup-and-dependency-injection.adoc#_disabling_components[]. | ||
|
|
||
| WARNING: Don't use `ConfigFactory.load()` since that will not load the `application.conf` as you intended. Use dependency injection of `Config` instead. |
There was a problem hiding this comment.
I know this was the concrete thing the user hit but I don't like notes about what APIs you shouldn't use, isn't it better with just the right way than to try to cover everything you could do that won't work?
Fixes https://github.com/lightbend/akka-runtime/issues/4512
Seems like we didn't have documentation of configuration at all, aside from specific features such as model provider config.