Skip to content
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

Adds sample for embedded wasm usage #122

Merged
merged 1 commit into from
Apr 11, 2023
Merged

Conversation

codefromthecrypt
Copy link
Contributor

@codefromthecrypt codefromthecrypt commented Nov 10, 2022

This introduces users to the idea that WebAssembly is embedded in the sidecar, by actually serving a request that way.

This will be more interesting when we add file watch support to the wasm middleware, which would allow people to reload wasm without restarting the process. dapr/components-contrib#2267

@codefromthecrypt
Copy link
Contributor Author

Note: as dapr v1.10 isn't out, you have to do this to get things working:

$ cd dapr
$ make
$ cp -p dist/*/release/* $HOME/.dapr/bin/

@msfussell
Copy link
Member

@codefromthecrypt - Can you update the README here https://github.com/dapr/samples#readme which is an index of the samples in the repo

@codefromthecrypt
Copy link
Contributor Author

@msfussell done. thanks!

@codefromthecrypt codefromthecrypt force-pushed the hello-wasm branch 2 times, most recently from 4c135ea to a87b224 Compare December 20, 2022 01:07
@codefromthecrypt
Copy link
Contributor Author

@daixiang0 mind reviewing/testing for merge? it would be nice to promote this with 1.10

hello-wasm/README.md Outdated Show resolved Hide resolved
This introduces users to the idea that WebAssembly is embedded in the
sidecar, by actually serving a request that way.

This will be more interesting when we add file watch support to the wasm
middleware, which would allow people to reload wasm without restarting
the process.

Signed-off-by: Adrian Cole <[email protected]>
@codefromthecrypt
Copy link
Contributor Author

@yaron2 I addressed @daixiang0 feedback, and also tested this, fixing a small CLI arg drift (components-path -> resources-path). Can we get this in?

In other words, it does not require a separate app to use.

To add custom middleware, you need a wasm binary (file with a `.wasm` extension),
compatible with [http-wasm](https://http-wasm.io/) middleware. You can re-use an
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, we say you can re-use or compile.. so that beginners don't feel they need to compile each time. good suggestion by @daixiang0

```
ℹ️ Starting Dapr with id embedded. HTTP Port: 3500. gRPC Port: 56067
...
INFO[0000] enabled middleware.http.wasm/http middleware app_id=embedded instance=MacBook-Pro.local scope=dapr.runtime type=log ver=1.10.4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as you can see by my updated logs, things work out-of-box 💯


go 1.19

require github.com/http-wasm/http-wasm-guest-tinygo v0.1.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rebuilt this today with latest tinygo. all good

@salaboy
Copy link

salaboy commented Mar 23, 2023

@msfussell @yaron2 is there something that I can do to help on this front, so this gets merged?

@yaron2 yaron2 merged commit d3a6145 into dapr:master Apr 11, 2023
@codefromthecrypt codefromthecrypt deleted the hello-wasm branch April 11, 2023 06:11
@codefromthecrypt
Copy link
Contributor Author

thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants