Hello! We (Etsy) are interested in adopting Dagger for server-side applications. We'd like to use dependency injection, but without the downsides of reflection and proxies. We're also Bazel users, so it's reassuring to know that combination is well-exercised.
I'm wondering if folks who are using Dagger on the server-side might pass along some ideas and best-practices for doing so. The documentation in this area is a little light, so any pointers would be helpful. A few areas of specific interest:
End-to-End Examples: So far the best OSS example I can find of server-side Dagger is Google
Nomulus. Are there others that are worth looking at?
Lifecycle management: For example, some of our services need to read in large files, connect to databases or caching services, etc. on startup before they're ready to serve traffic. Spring and Micronaut handle this via the PostConstruct annotation, but Ron Shapiro
had suggested using method injection to achieve the same thing. Is that still the best advice?
Static Configuration: We'd like to be able to inject static configuration -- system properties, environment variables, and config files. In Nomulus, a POJO is created representing a large set of configuration (
example) and the @Provides methods (
example) and qualifiers (
example) make subsets of this configuration available for injection. Is this good practice? Is there anything better? It's a bit more verbose to setup than @Value from Spring/Micronaut, but I like having the config consolidated and well typed.
Dynamic Configuration: We also have dynamic configuration variables that we would like to inject. These can change during our service's lifetime. For example, a list of database replicas might change when databases get replaced or scaled up. But we don't want to go to a config service on each reference to the list of databases -- after the data changes, it should be locally available. The interface I think we'd want for this is something like
Supplier<T> with T being the type of configuration data. Any ideas or examples? The Spring/Micronaut solution of @
RefreshableScope seems to makes the dynamic nature of the data somewhat opaque to the callee.
Thanks in advance!