-
Notifications
You must be signed in to change notification settings - Fork 144
Added some docs on plugins. #500
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
Open
Miro-Andrin
wants to merge
5
commits into
feather-rs:main
Choose a base branch
from
Miro-Andrin:plugin_docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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. | ||
|
||
```bash | ||
cargo install --path <path to quill> | ||
``` | ||
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 <name> | ||
``` | ||
|
||
This creates a simple test plugin called <name>. To build this example plugin head into the directory of the plugin (with the Cargo.toml in it) and run: | ||
|
||
```bash | ||
cargo-quill build | ||
``` | ||
|
||
|
||
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. | ||
|
||
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. | ||
|
||
|
||
|
||
## 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. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
<path to quill>
? Do I need to build cargo-quill first?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, If i change it to cargo-quill, does that spark joy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just not sure why you're using a placeholder. You could say "In the root directory of feather, run the following command" followed by
cargo install --path quill/cargo_quill/
or you could also say "Navigate into quill/cargo_quill and run the following command", followed bycargo install --path .
.