Replies: 7 comments 13 replies
-
Additionally to subprocess, I wonder if WASM would fit the bill? We could load them via https://github.com/tetratelabs/wazero so no CGo dep compared to some of the other WASM libs. |
Beta Was this translation helpful? Give feedback.
-
I came across this thread which has some nice links to scripting plugin options and some benchmarks. I also have some experience writing tooling in Starlark. Having Python-ish syntax, with the ability to easily wrap underlying Go functions makes for a nice way to build plugins without a lot of the downsides that things like WASM or external process management has. |
Beta Was this translation helpful? Give feedback.
-
Regarding the |
Beta Was this translation helpful? Give feedback.
-
I'm trying to come up with a folder structure for the plugins. Right now everything is out of At the base of the directory, there will be:
When a plugin is uploaded it will land into |
Beta Was this translation helpful? Give feedback.
-
An events system would be pretty useful too, like general system state changes etc. Potentially in a pubsub form? |
Beta Was this translation helpful? Give feedback.
-
Actually, I am going to remove the requirement for RPC communication from the plugin system. If the plugin connects to the rpc endpoint, then it must implement the |
Beta Was this translation helpful? Give feedback.
-
Simple UI FrameworkOut of scope for the current PR, and goal of the system, but would come in handy nevertheless. I have two schools of thought for it:
Once registered, clicking/interacting with controls could call an interactivity event RPC on the plugin with the ID of the control, and any payload data, such as text-box input, drop-down selection etc. There would also need to be a way for plugins to request user input, for example, by calling an RPC that opens a modal requesting the user choose an option, or enter some text. The users response could then be sent back in the same way (by sending an interactivity event) This would allow for plugins to be much more integrated into the system, but might blur the line between what should be a plugin, vs what should be upstreamed? Maybe not, just thinking as I type... All in all, having the UI managed by the plugin infrastructure allows us the control the UI/UX for the user (keeping everything consistent between JetKVM's app, and the plugins) and avoids multiple plugins trying to build their own way of interacting with the plugin. I think, if we were to do this, it'd be worth adding an extra action bar that appears as necessary, under the JetKVM action bar. Multi-port Serial Extension UI IdeaJust a random idea that implements the UI: An extension board that has multiple RS232 interfaces and connects to JetKVM with the extension port. It has it's own plugin on the KVM that creates 4 buttons on the "extension action bar" to switch between the ports. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As people want to build more and more features into the JetKVM ecosystem, being able to add additional subprocess executables that can communicate back with the main process will be important for maintaining scalability. I propose a plugin architecture to address these concerns.
The plugin architecture will be built off of subprocesses spawned by the main jetkvm_app process. Each plugin with have an RPC mechanism to talk back with the app process via JSON RPC, to maintain similar technology used other places in the system. This communication will happen with plugin-specific unix sockets created by the app process, and passed in as a
JETKVM_PLUGIN_SOCK
environment variable when the subprocess is spawned. The plugin should connect to this socket when spawned, and use it for communications with the main process.Every plugin will start as a tar archive where the root contains a
manifest.json
file in the following format, with additional fields that could be added in the future for additional metadata.Most importantly, the
bin
property describes the location of the binary to run as a subprocess for this executable. This binary should be bundled in the tar archive. Additional files can also be bundled in the archive, which will be accessible to the process relative to the root of the executable. How JetKVM discovers where to download these tar balls can be defined later, with the first implementation probably being a simple upload from the web ui, with later implementations potentially including a marketplace-style setup. Thesystem_min_version
(optional) defines the minimum version of the JetKVM that the plugin supports. If the plugin requires a newer version than what is currently running, the system should not attempt to start the plugin.When a plugin starts up, it can optionally connect to
JETKVM_PLUGIN_SOCK
as a JSON RPC endpoint. The plugin should implement both a JSON RPC client and server, allowing bidirectional communication over the same socket. There should be at a minimum thegetPluginSupportedMethods
method implemented by the plugin, withgetPluginStatus
highly recommended.Plugin Methods
getPluginSupportedMethods()
Initiated from jetkvm_app to the plugin to determine which RPC methods the plugin supports. Should return an object with a list of methods. The list must contain
getPluginSupportedMethods
to be a valid plugin.getPluginStatus()
Initiated from jetkvm_app to the plugin to determine the readiness and health of the plugin. This rpc method may be called at any time and a response with the following parameters should be provided in a timely manor
getPluginConfiguration()
Called by jetkvm_app to determine what options to show to the user in the web-ui and how that maps back to configuration values. The payload consists of two main fields: "data" and "schema". The format of "schema" is to be determined in the future, but may be a small variation on JSON schema with extensions added to support automatic UI generation. The "data" field will be a JSON object opaque to the plugin system and directly editable in the web interface.
Plugins are responsible for persisting their own configuration if needed. An environment variable
JETKVM_PLUGIN_WORKING_DIR
will be provided to give the plugin a consistent and durable location to store files.If this method is implemented, the
updatePluginConfiguration
method should also be implemented. If neither are implemented, then the UI won't provide any plugin-specific configuration options.updatePluginConfiguration(config: any)
Called whenever the plugin's configuration is updated through the WebUI. The payload consists of an opaque JSON object that can be managed by the plugin however it sees fit. The plugin should be responsible for handling the lifecycle of configuration changes gracefully without needing to be restarted.
Beta Was this translation helpful? Give feedback.
All reactions