-
Notifications
You must be signed in to change notification settings - Fork 229
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
How to properly make dependency injection with ServiceWeaver #419
Comments
Hi @Markbnak, does |
Thank you for sharing this, I haven't seen that feature in the documentation. |
@mwhittaker, I think that this suits my use case. |
@mwhittaker I managed to resolve my issue, this code example was what I was looking for. I hope you will document that on your website. |
Awesome! I opened #430 for this as well! |
I'm trying to implement the dependency injection pattern in my code.
I need it because we need to mock results from an external API during tests.
Here is a sample of what I'm trying to achieve:
Service calling external data
Service
Tests
The calling service
The whole problem is how to tell the
service
package whichDependency_fn
function to use when calling it fromsecondService
package.The tests I developed work perfectly and I am able to use the mock function.
I read a similar issue: #188
In the discussion it is suggested to use
weaver.Get[Foo]
, but this provides me compilation errors such as:undefined: weaver.get
For these examples I tried versions v0.13.0 and v0.16.0.
The text was updated successfully, but these errors were encountered: