-
-
Notifications
You must be signed in to change notification settings - Fork 545
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
Async APIs #269
Comments
Thanks for idea! Another interesting idea is to load plugins in parallel (if a plugin is not a dependency for another plugin we can load them in parallel) to decrease the startup time of application. But I consider these kind of features somehow enterprise. I am curios to see how we can implement this feature in a clean and non intrusive way. Any draft, snippet code, idea that will move forward this feature or a concrete PR is welcome. |
And to not forget, to use |
@decebals I'll sketch something. The bigger challenge is how to keep it backward compatible. Otherwise, it has to be targeted for 3.x, I guess |
3.x is perfect. For 3.x we will increase the minimal Java version to 8. |
I am thinking if it's not possible to add new default async methods in |
This feature will be removed from PF4J 3 milestone, because the interest for this feature is low. |
I added a POC (Proof Of Concept) on the async branch. |
I added below two code snippets (from
Load and start plugins sync// create the plugin manager
final PluginManager pluginManager = new DefaultPluginManager();
// load the plugins
pluginManager.loadPlugins();
// start (active/resolved) the plugins
pluginManager.startPlugins();
// retrieves the extensions for Greeting extension point
List<Greeting> greetings = pluginManager.getExtensions(Greeting.class); Load and start plugins async// create the plugin manager
final AsyncPluginManager pluginManager = new DefaultAsyncPluginManager();
// load the plugins
CompletionStage<Void> stage = pluginManager.loadPluginsAsync();
stage.thenRun(() -> System.out.println("Plugins loaded")); // optional
// start (active/resolved) the plugins
stage.thenCompose(v -> pluginManager.startPluginsAsync());
stage.thenRun(() -> System.out.println("Plugins started")); // optional
// block and wait for the future to complete (not the best approach in real applications)
stage.toCompletableFuture().get();
// retrieves the extensions for Greeting extension point
List<Greeting> greetings = pluginManager.getExtensions(Greeting.class); I am not sure yet if the variant with new |
To the solution proposed by me can be added support for timeout via CompletableFeature.orTimeout (Java 9+) or a similar method using |
In the end, what you say about the POC (Proof Of Concept) on the async branch? Is it valuable to be included in the PF4J roadmap? |
Hi!
Would you consider supporting Async APIs?
There are some IO blocking operations (e.g. loading of plugins, or even plugin's startup), and currently, in my async non-blocking app, I have to run them in a special thread pool (although the implementations of the plugin repository and plugins themselves are async)
CompletionStage<Void>
could be used in place of potentially-IO methods withvoid
type, andCompletionStage<T>
where it returns something.Consider this issue as a feature request & design discussion for now :)
The text was updated successfully, but these errors were encountered: