-
-
Notifications
You must be signed in to change notification settings - Fork 659
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
Add a plugin system #119
Add a plugin system #119
Conversation
update example config
set core pool sizes to at least one
add example plugin
call onStart() after SocketServer is ready
- DirectoryPluginFinder$FileIterator now returns all files, not just classes - PluginFinder keeps a cache of all known entries, generated on first use - PluginFinder subclasses must also define a createURL(String) method
- allow disabling individual plugins - log plugin names during load
It looks like the classloading is handled after Spring has started. To my understanding, this means that dependency injection isn't applied to these classes. If plugins are subject to dependency injection it would allow much greater flexibility. The obvious problem is that the classloading requires the plugin configuration to be loaded by Spring. Perhaps this problem can be solved by using an initial spring context to only loads this configuration before the full application is launched. |
In addition to documentation (an example is not enough), I think this feature needs a boilerplate project that developers can fork. This would probably be a separate repo with an example plugin similar to the one you showed. Would you be interested in working on such a boilerplate, or should I? |
remove extra space in main build.gradle
I tried getting jitpack to build the server so it could be added as a dependency on the boilerplate project, but there's currently no support for jdk 10, so this happens. A temporary workaround would be setting server source/target compatibility to 9, at the cost of not using java 10 features (although none are used currently, and building with target as java 9 works). |
Put this into the jitpack.yml:
|
Why are you trying to publish the server via jitpack tho? It's a standalone application, not a library. |
To be able to write this
without having to copy lavalink classes/source to the project |
Imo that means Lavalink should publish a public API / contract, not the whole server project. |
move PluginManager#callOnOpen() invocation to the correct place
Linkink to the server allows plugins to access server classes, and eg read server configurations with spring dependency injection. While a public API could be implemented to provide similar functionality, it would limit access to server code or require adding all methods to it, which is why I chose to have the server as a (compileOnly) dependency. |
No public API / contract and importing the whole thing means downstream will just have to eat any changes to the server project. |
@napstr how's this? |
Creating an interface of all the important internal classes does not make an acceptable public API in my eyes. |
This PR seems, for a reason I don't understand, insisting on making internal Lavalink classes public API. |
@natanbc it would be great if you outlined what sort of functionality you want plugins to access. It's difficult to construct an API if you don't know what the goal is. Judging by your code one such goal is to support custom WS ops. Let's say we want plugins to define custom WS ops. Instead of directly overriding the methods in the WS server, we could instead allow plugins to register ops on a per-plugin basis, which will be invoked if the ops are not already defined directly in the server. This wouldn't touch on any internal class from the plugin's perspective. |
Currently it allows loading from both jars and folders with classes.
An example implementation can be found in LavalinkServer/src/example-plugin