Update docs for bindings

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
This commit is contained in:
Edoardo Vacchi 2023-07-24 18:04:20 +02:00
parent f7f6b0639e
commit 3dbf63f7b4
2 changed files with 19 additions and 10 deletions

View File

@ -36,9 +36,10 @@ Wasm binaries are loaded from a URL. For example, the URL `file://rewrite.wasm`
loads `rewrite.wasm` from the current directory of the process. On Kubernetes, loads `rewrite.wasm` from the current directory of the process. On Kubernetes,
see [How to: Mount Pod volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}}) see [How to: Mount Pod volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}})
to configure a filesystem mount that can contain Wasm binaries. to configure a filesystem mount that can contain Wasm binaries.
It is also possible to fetch the wasm binary from a remote URL. In this case, It is also possible to fetch the Wasm binary from a remote URL. In this case,
the URL must point exactly to one wasm binary, e.g.: the URL must point exactly to one Wasm binary. For example:
`http://example.com/rewrite.wasm` or `https://example.com/rewrite.wasm`. - `http://example.com/rewrite.wasm`, or
- `https://example.com/rewrite.wasm`.
Dapr uses [wazero](https://wazero.io) to run these binaries, because it has no Dapr uses [wazero](https://wazero.io) to run these binaries, because it has no
dependencies. This allows use of WebAssembly with no installation process dependencies. This allows use of WebAssembly with no installation process
@ -99,16 +100,23 @@ spec:
value: "https://github.com/vmware-labs/webassembly-language-runtimes/releases/download/ruby%2F3.2.0%2B20230215-1349da9/ruby-3.2.0-slim.wasm" value: "https://github.com/vmware-labs/webassembly-language-runtimes/releases/download/ruby%2F3.2.0%2B20230215-1349da9/ruby-3.2.0-slim.wasm"
``` ```
Then, the following request would respond back with "Hello, salaboy": Assuming that you started your Wasm Binding at port 3500, you'd run:
```json ```
$ dapr run --app-id wasm --dapr-http-port 3500 --resources-path components
```
The following request responds `Hello "salaboy"`:
```sh
$ curl -X POST http://localhost:3500/v1.0/bindings/wasm -d'
{ {
"operation": "execute", "operation": "execute",
"metadata": { "metadata": {
"args": "-ne,'print \"Hello, \"; print'" "args": "-ne,print \"Hello \"; print"
}, },
"data": "salaboy" "data": "salaboy"
} }'
``` ```
## Related links ## Related links

View File

@ -21,9 +21,10 @@ Wasm binaries are loaded from a URL. For example, the URL `file://rewrite.wasm`
loads `rewrite.wasm` from the current directory of the process. On Kubernetes, loads `rewrite.wasm` from the current directory of the process. On Kubernetes,
see [How to: Mount Pod volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}}) see [How to: Mount Pod volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}})
to configure a filesystem mount that can contain Wasm modules. to configure a filesystem mount that can contain Wasm modules.
It is also possible to fetch the wasm binary from a remote URL. In this case, It is also possible to fetch the Wasm binary from a remote URL. In this case,
the URL must point exactly to one wasm binary, e.g.: the URL must point exactly to one Wasm binary. For example:
`http://example.com/rewrite.wasm` or `https://example.com/rewrite.wasm`. - `http://example.com/rewrite.wasm`, or
- `https://example.com/rewrite.wasm`.
## Component format ## Component format