From 03536c1496d17889ae601eb9bcd63359777e2d70 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 30 Apr 2023 14:30:26 +0800 Subject: [PATCH] wasm middleware: change path property to url This changes the configuration item for the Wasm binary from path to url. In doing so, we ease migration from other sources including HTTP and OCI. Signed-off-by: Adrian Cole --- .../supported-middleware/middleware-wasm.md | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md b/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md index 8d19d0b19..21700afad 100644 --- a/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md +++ b/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md @@ -17,9 +17,10 @@ binary. In other words, you can extend Dapr using external files that are not pre-compiled into the `daprd` binary. Dapr embeds [wazero](https://wazero.io) to accomplish this without CGO. -Wasm modules are loaded from a filesystem path. On Kubernetes, see [mounting -volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}}) to configure -a filesystem mount that can contain Wasm modules. +Wasm modules are loaded from a URL. For example, a URL "file://rewrite.wasm" +loads "rewrite.wasm" from the current directory of the process. On Kubernetes, +see [mounting volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}}) +to configure a filesystem mount that can contain Wasm modules. ## Component format @@ -32,8 +33,8 @@ spec: type: middleware.http.wasm version: v1 metadata: - - name: path - value: "./router.wasm" + - name: url + value: "file://router.wasm" ``` ## Spec metadata fields @@ -41,9 +42,9 @@ spec: Minimally, a user must specify a Wasm binary implements the [http-handler](https://http-wasm.io/http-handler/). How to compile this is described later. -| Field | Details | Required | Example | -|----------|----------------------------------------------------------------|----------|----------------| -| path | A relative or absolute path to the Wasm binary to instantiate. | true | "./hello.wasm" | +| Field | Details | Required | Example | +|-------|----------------------------------------------------------------|----------|----------------| +| url | The URL of the resource including the Wasm binary to instantiate. The supported schemes include "file://". The path of a "file://" URL is relative to the Dapr process unless it begins with '/'. | true | "file://hello.wasm" | ## Dapr configuration @@ -109,7 +110,7 @@ func handleRequest(req api.Request, resp api.Response) (next bool, reqCtx uint32 ``` If using TinyGo, compile as shown below and set the spec metadata field named -"path" to the location of the output (ex "router.wasm"): +"url" to the location of the output (ex "file://router.wasm"): ```bash tinygo build -o router.wasm -scheduler=none --no-debug -target=wasi router.go` @@ -145,7 +146,7 @@ func rewrite(requestURI []byte) ([]byte, error) { ``` If using TinyGo, compile as shown below and set the spec metadata field named -"path" to the location of the output (ex "example.wasm"): +"url" to the location of the output (ex "file://example.wasm"): ```bash tinygo build -o example.wasm -scheduler=none --no-debug -target=wasi example.go