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
Guice EDSL for ServiceGraphBuilder #999
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ServiceGraphs may now be built by installing special modules in a KAbstractModule#configure() method via a simple API. e.g. If we have Services{A,B,C,D,E} in the following configuration: ``` ServiceA depended on by ServiceB enhanced by ServiceC depended on by ServiceD depended on by ServiceE ``` Then we can register these services in that configuration with a module as follows: ``` val injector = Guice.createInjector(object: KAbstractModule() { override fun configure() { install(service<ServiceA>()) install(service<ServiceB>() .dependsOn<ServiceA>() .enhancedBy<ServiceC>() ) install(service<ServiceC>()) install(service<ServiceD>().dependsOn<ServiceA>()) install(service<ServiceE>().dependsOn<ServiceD>()) } }) ``` And obtain a service manager by: ``` val builder = injector.getInstance<ServiceGraphBuilder>() val serviceManager = builder.build() ``` In future commits: - Once everything in Misk is migrated to be provided a ServiceGraphBuilder, change the implementation of provideServiceManager to obtain and build the ServiceGraph instead of requiring modules to build the serviceManager themselves
swankjesse
approved these changes
May 21, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow-up for #984. This PR introduces a small EDSL to specify Service dependencies and enhancements.
This provides a
ServiceModule
which can be installed to other modules, providing an easy way to build Service dependency graphs with Guice.The new provider method
provideServiceGraphBuilder
creates a builder for the graph. It is intended to supercede theprovideServiceManager
method (see note) as we migrate from CoordinatedService to CoordinatedService2.Next steps will be to deprecate CoordinatedService and DependentService, then migrate modules to specify their graphs using the EDSL, like in the simple example below: