-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow modules to be provided multiple times application #892
Comments
Hey there, apologies for the delay in response. We do not allow the same type to be provided multiple times in the application. We're planning to work on a public documentation site for fx that will explain some of the core thoughts behind this, but just referring to the specific case you are bringing up here, it is easier if there is a top-level library that groups and provides the most commonly used dependencies (i.e. things like config, or logger, or metrics).
The error is specifically coming from the same That being said, if we can track things by a |
I'm trying to achieve a functional behavior similar to spring boot's My ultimate goal it to make it easier for developers to move from our java/spring-boot based applications to cloud/container/lambda friendly Go lang apps. |
I think the request here is that
should be idempotent, so it can occur multiple times with the same effect as once. That's slightly different from
where both construct the same type -- this is a genuine conflict between two different constructors. The first case is very useful in large applications for exactly the mentioned reason: it's a lot easier to structure code to just declare its dependencies, and allow repeated declarations, than to try to find the "right" place to put a single declaration that is needed in multiple places. In the implementation I'm building now, I've collected types into "bundles" and then each bundle has a doc comment saying what other bundles it depends on, relying the author of each Is there a way to distinguish the two named cases with |
Another option to implement this feature, and allow the framework in general to be mode flexible, would be to allow users to create custom |
I'm currently working on reusable modules for common infrastructure like database, MQ, ID provider, etc and these modules may also depends on other sub-modules, such as a config server.
Ideally, I'd like to declare my modules as follows:
Currently, if I declare my modules as previously mentioned, I'll get an "already provided" error, which is not ideal because the user of the database and oidc modules would not be aware of it's dependencies.
The framework, could keep track of the modules that have already populated the container and skip it if already processed.
The text was updated successfully, but these errors were encountered: