Skip to content

Commit

Permalink
docs: Add proto v0.28 blog post. (#1275)
Browse files Browse the repository at this point in the history
Add blog post.
  • Loading branch information
milesj authored Jan 17, 2024
1 parent 3b57c40 commit 18d7c16
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
33 changes: 33 additions & 0 deletions website/blog/2024-01-17_proto-v0.28.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
slug: proto-v0.28
title: proto v0.28 - Upgraded WASM runtime
authors: [milesj]
tags: [proto, wasm, runtime, extism]
# image: ./img/proto/v0.26.png
---

This is a small release that primarily upgrades our WASM runtime.

<!--truncate-->

## Upgraded WASM runtime

proto utilizes [Extism](https://extism.org/) for our WASM plugin architecture, which internally uses
[wasmtime](https://wasmtime.dev/) as our execution runtime. Up until this point, we've been using a
beta release of Extism, v0.5, which has worked quite nicely. We've also been working closely with
the Extism team to report bugs, provide feedback, and help improve the project. Once such feature
was the massive performance gains in [proto v0.24](./proto-v0.24).

Thanks to all the hard work from the Extism team over the past year, an official v1.0 was released.
Because this was a major release, it did include breaking changes around the WASM runtime, and as
such, proto WASM plugins before v0.28 are _no longer compatible_, and will need to be recompiled
with the latest PDKs. Our proto TOML plugins are not affected.

## Other changes

View the [official release](https://github.com/moonrepo/proto/releases/tag/v0.28.0) for a full list
of changes.

- Will now display an upgrade message when the current proto version is out of date.
- Improved error messages to include plugin specific information.
- Updated our "last used at" logic to avoid race conditions with the tool manifest.
16 changes: 12 additions & 4 deletions website/docs/proto/wasm-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ provide a mechanism known as host functions, which are functions that are implem

- [`exec_command`](https://docs.rs/proto_pdk/latest/proto_pdk/macro.exec_command.html) - Execute a
system command on the host machine, with a provided list of arguments or environment variables.
- [`from_virtual_path`](https://docs.rs/proto_pdk/latest/proto_pdk/macro.real_path.html) - Converts
a virtual path into a real path.
- [`get_env_var`](https://docs.rs/proto_pdk/latest/proto_pdk/macro.host_env.html) - Get an
environment variable value from the host environment.
- [`host_log`](https://docs.rs/proto_pdk/latest/proto_pdk/macro.host_log.html) - Log a message to
the host's stderr. This acts like tracing logs, and is not a general purpose stdout logger.
- [`set_env_var`](https://docs.rs/proto_pdk/latest/proto_pdk/macro.host_env.html) - Set an
environment variable to the host environment.
- [`to_virtual_path`](https://docs.rs/proto_pdk/latest/proto_pdk/macro.virtual_path.html) - Converts
a real path into a virtual path.

To use host functions, you'll need to make them available by registering them at the top of your
Rust file (only add the functions you want to use).
Expand All @@ -106,9 +110,11 @@ Rust file (only add the functions you want to use).
#[host_fn]
extern "ExtismHost" {
fn exec_command(input: Json<ExecCommandInput>) -> Json<ExecCommandOutput>;
fn get_env_var(key: &str) -> String;
fn from_virtual_path(path: String) -> String;
fn get_env_var(key: String) -> String;
fn host_log(input: Json<HostLogInput>);
fn set_env_var(key: &str, value: &str);
fn set_env_var(key: String, value: String);
fn to_virtual_path(path: String) -> String;
}
```

Expand All @@ -118,6 +124,9 @@ extern "ExtismHost" {
// Set a value
host_env!("ENV_VAR", "value");

// Append to path
host_env!("PATH", "/userhome/some/virtual/path");

// Get a value (returns an `Option`)
let value = host_env!("ENV_VAR");
```
Expand All @@ -136,8 +145,7 @@ exec_command!(inherit, "npm", ["install"]);
exec_command!(ExecCommandInput {
command: "npm".into(),
args: vec!["install".into()],
env_vars: HashMap::new(),
stream: false,
..ExecCommandInput::default()
});
```

Expand Down

0 comments on commit 18d7c16

Please sign in to comment.