From 07aff4e98f290cc0f93a9a8a0c607cb6bfc69157 Mon Sep 17 00:00:00 2001 From: Miro Date: Thu, 30 Sep 2021 22:04:59 +0200 Subject: [PATCH 1/5] Added some docs on plugins. --- docs/plugins.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 docs/plugins.md diff --git a/docs/plugins.md b/docs/plugins.md new file mode 100644 index 000000000..626589d9c --- /dev/null +++ b/docs/plugins.md @@ -0,0 +1,51 @@ +# Feather - Quill - Plugins +Feather has support for plugins. They can either be run as native code, or through WebAssembly using [Wasmer](https://github.com/wasmerio/wasmer). The API for the two options are the same, but wasmer has a few benefits for the cost of slightly worse performance. ([More details](#Wasm-or-Native)). + +## Getting Started + +# Building and Running +To build a quill plugin you will need a tool called [cargo-quill](https://github.com/¨-rs/feather/tree/main/quill/cargo-quill). To install cargo quill you need the [rust build tools](https://www.rust-lang.org/tools/install), and clone Feathers [git repository](https://github.com/feather-rs/feather). + +Once that is setup, locate the folder `feather/quill/cargo_quill` in a terminal. Then run the following command. + +```bash +cargo install --path +``` +This adds `cargo-quill` to path, which can be tested by running. +```bash +cargo-quill --help +``` + +To create a plugin run the following command. +```bash +cargo-quill new +``` + +This creates a simple test plugin called . To build this example plugin head into the directory of the plugin (with the Cargo.toml in it) and run: + +```bash +cargo-quill build +``` + + +When building a plugin it can either be done in `release` or `debug` mode. By default it builds in debug mode, but if passed the `--release` flag it builds it in release mode. Debug mode creates slower plugins, however they are built a lot faster, making it quicker to get started. The --native option changs what the plugin is compiled into. By default it compiles to a wasm plugin, but --native gives the native version. + + +Once finished the command will have created a file ending in '.plugin'. It is placed in either `/target/release` or `/target/debug` depending on if the release flag is provided. + +To test the plugin a feather server binary is needed. Inside the folder where the binary located, you need to locate or create a folder called `plugins`. Put the '.plugin' there and run the server. + + + +## Wasm or Native? + +### Wasm +Wasm comes with the added benefit of running in a "sandbox", which means that if a plugin at any points crashes it won't take down whole server immediately. The server can try to restart it, but if all else fails shuts down the server gracefully. + +Wasm plugins manage their own memory, and don't directly share the same memory as the rest of the server, what system it was compiled on doesn't affect anything either. + +Since Wasm is designed to only do computation it doesn't have any IO capabilities in normal cases, this means plugins compiled to Wasm won't be able to do any logging or save/load configuration files by their own means. They are limited to use the api that Feather provides. + +### Native +Native comes with an advantage when it comes to performance, it was built to run on your specific system and needs to be compiled for it. +It comes with a downside though, if a native plugin crashes the entire server crashes. From 9e39d387fb1fa0187bebac213d370f2d46cec9dd Mon Sep 17 00:00:00 2001 From: Miro-Andrin Date: Fri, 1 Oct 2021 16:57:41 +0200 Subject: [PATCH 2/5] Update docs/plugins.md Co-authored-by: Tim Kt --- docs/plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins.md b/docs/plugins.md index 626589d9c..84a45e335 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -4,7 +4,7 @@ Feather has support for plugins. They can either be run as native code, or throu ## Getting Started # Building and Running -To build a quill plugin you will need a tool called [cargo-quill](https://github.com/¨-rs/feather/tree/main/quill/cargo-quill). To install cargo quill you need the [rust build tools](https://www.rust-lang.org/tools/install), and clone Feathers [git repository](https://github.com/feather-rs/feather). +To build a quill plugin you will need a tool called [cargo-quill](https://github.com/¨-rs/feather/tree/main/quill/cargo-quill). To install cargo quill you need the [rust build tools](https://www.rust-lang.org/tools/install), and clone Feather's [git repository](https://github.com/feather-rs/feather). Once that is setup, locate the folder `feather/quill/cargo_quill` in a terminal. Then run the following command. From fd548799d3088c69eaff1649fdad2304df4509b4 Mon Sep 17 00:00:00 2001 From: Miro-Andrin Date: Fri, 1 Oct 2021 16:58:06 +0200 Subject: [PATCH 3/5] Update docs/plugins.md Co-authored-by: Tim Kt --- docs/plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins.md b/docs/plugins.md index 84a45e335..642384ca4 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -6,7 +6,7 @@ Feather has support for plugins. They can either be run as native code, or throu # Building and Running To build a quill plugin you will need a tool called [cargo-quill](https://github.com/¨-rs/feather/tree/main/quill/cargo-quill). To install cargo quill you need the [rust build tools](https://www.rust-lang.org/tools/install), and clone Feather's [git repository](https://github.com/feather-rs/feather). -Once that is setup, locate the folder `feather/quill/cargo_quill` in a terminal. Then run the following command. +Once that is setup, locate the folder `feather/quill/cargo-quill` in a terminal. Then run the following command. ```bash cargo install --path From b185a60501e599e2fdb260b471d3b1c433b4cf63 Mon Sep 17 00:00:00 2001 From: Miro-Andrin Date: Fri, 1 Oct 2021 17:21:35 +0200 Subject: [PATCH 4/5] Update docs/plugins.md Co-authored-by: Tim Kt --- docs/plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins.md b/docs/plugins.md index 642384ca4..55551ee0e 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -33,7 +33,7 @@ When building a plugin it can either be done in `release` or `debug` mode. By de Once finished the command will have created a file ending in '.plugin'. It is placed in either `/target/release` or `/target/debug` depending on if the release flag is provided. -To test the plugin a feather server binary is needed. Inside the folder where the binary located, you need to locate or create a folder called `plugins`. Put the '.plugin' there and run the server. +To test the plugin, a feather server binary is needed. Inside the folder where the binary is located, create a folder `plugins` (if it doesn't already exist). Put the '.plugin' there and run the server. From 7551b1bc19901c7365c43df02e0d3aeb9e78ef72 Mon Sep 17 00:00:00 2001 From: Miro-Andrin Date: Fri, 1 Oct 2021 17:30:46 +0200 Subject: [PATCH 5/5] Update docs/plugins.md Co-authored-by: Tim Kt --- docs/plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins.md b/docs/plugins.md index 55551ee0e..a1dfd51dd 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -28,7 +28,7 @@ cargo-quill build ``` -When building a plugin it can either be done in `release` or `debug` mode. By default it builds in debug mode, but if passed the `--release` flag it builds it in release mode. Debug mode creates slower plugins, however they are built a lot faster, making it quicker to get started. The --native option changs what the plugin is compiled into. By default it compiles to a wasm plugin, but --native gives the native version. +By default, the plugin will be built in `debug` mode. The build process will be fast, but the plugin itself will be slower. By specifying the `--release` flag, you can build the plugin in `release` mode, which will take longer, but results in a faster plugin. Without any other flags, the plugin will be compiled to a wasm plugin. If you want to compile it to native code, add the `--native` flag. Once finished the command will have created a file ending in '.plugin'. It is placed in either `/target/release` or `/target/debug` depending on if the release flag is provided.