I
I
index0h2015-07-27 02:09:20
go
index0h, 2015-07-27 02:09:20

Is there a configurable DI for golang?

Hello everyone, I ran into such a problem: during the start of the application, it is necessary to resolve a huge number of dependencies between the main components of the system. At the same time, some of them need to be able to be configured at the time of launch, and not at the build stage to set parameters.
Following the link , I sketched an approximate structure of components, some of them are optional, some are interchangeable. I did not make links through yaml aliases in order to preserve the structure with a minimum number of levels. "%...%" is a reference to another component.
Actually, a certain DI container is required that could resolve dependencies in lazy-load mode, while not compiling hard into a binary, but requesting its settings dynamically.
Here is this golangit/dicalready poked, with private properties it didn’t start + requires a rigid system of dependencies. Of course, you can add parsing of the same yaml (viper for example) and do it dynamically, but then it’s already easier to write all these calls by hand.
Of course, such a thing must have some register of constructors.
To summarize, have you encountered similar problems, how did you solve them? Is there something ready?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-07-27
@index0h

Your task is not solved through the dependency container - if you need to slip the necessary implementation in runtime - this is solved through some factories that the container already provides you with all the necessary dependencies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question