second-state / dapr-wasm Goto Github PK
View Code? Open in Web Editor NEWA template project to demonstrate how to run WebAssembly functions as sidecar microservices in dapr
License: Apache License 2.0
A template project to demonstrate how to run WebAssembly functions as sidecar microservices in dapr
License: Apache License 2.0
Hi,
I am performing the grayscale tutorial example i.e. make run-api-rs
the following error is occurring.
ERRO[0000] error getting topics from app: unexpected end of JSON input app_id=image-api-rs instance=wasm-oci-demo scope=dapr.runtime type=log ver=1.4.2
ERRO[0000] error occurred while beginning pubsub messages: error getting topics from app: unexpected end of JSON input app_id=image-api-rs instance=wasm-oci-demo scope=dapr.runtime type=log ver=1.4.2
INFO[0000] dapr initialized. Status: Running. Init Elapsed 9.416037000000001ms app_id=image-api-rs instance=wasm-oci-demo scope=dapr.runtime type=log ver=1.4.2
The following video (which starts just as the error occurs) demonstrates the above error in action.
https://youtu.be/A5EhO7cNTCw?t=392
It seems that dapr list
is displaying the correct output (in terms of apps, ports etc.)
wasmedge@wasm-oci-demo:~$ dapr list
APP ID HTTP PORT GRPC PORT APP PORT COMMAND AGE CREATED PID
go-web-port 3500 40659 8080 ./web-port 36s 2021-10-05 02:38.25 334410
image-api-rs 3502 34493 9004 ./target/debug/im... 23s 2021-10-05 02:38.38 334530
image-api-go 3501 40639 9003 ./image-api-go 9s 2021-10-05 02:38.52 334658
Is it possible that the grayscale needs to be added to the config i.e. https://github.com/second-state/dapr-wasm/blob/main/config/conf.json
Any suggestions would be greatly appreciated.
Thanks
Tim
The grayscale
service only supports the GIF and PNG formats. But the classify
service only supports the JPG format. Can we make them consistent?
Perhaps supports JPGs by default in both services? Thanks.
I have configured GitHub Pages to serve from the main
branch's root directory. So, our static web page is now available here:
https://second-state.github.io/dapr-wasm/web/
We do not actually need a GitHub Action for this. As soon as we update the main
branch, it will be automatically deployed.
We could, however, to use GitHub Actions to copy just the /web
folder to another branch (e.g., gh-pages
) and then deploy the gh-pages
branch as the web site's root.
We would like to create two sidecars that are just wasmedge
or wasmedge-tensorflow-lite
. Instead of using GO or Rust to implement HTTP servers and then bootstrap wasmedge, we would just run those wasmedge-based server apps in sidecars.
Sidecar #1: implement the grayscale function in Rust.
https://github.com/second-state/wasmedge_wasi_socket/tree/main/examples/http_server
Sidecar #2: implement the tensorflow function in JS
https://github.com/second-state/wasmedge-quickjs#http-request
https://github.com/second-state/wasmedge-quickjs#tensorflow
https://www.secondstate.io/articles/embed-javascript-in-rust/
After that, modify the web port to show all 4 sidecar apps.
I do not think we need the functions
folder anymore? Thanks.
I see there are multiple article link to this repo with obsolete information:
https://www.infoq.com/articles/webassembly-dapr-wasmedge/?utm_source=email&utm_medium=Web-Development&utm_campaign=newsletter&utm_content=11162021
https://wasmedge.org/book/en/use_cases/frameworks/mesh/dapr.html
It seems above links are having a Golang microservice, I think it's better if you can maintain both repo or update again the article.
Thanks
https://github.com/second-state/dapr-wasm/blob/main/image-api-go/image_api.go#L50
The resource loaded seems not exist. Besides would you mind provide the code before compiling into wasm?
when i run the image-api-go upload hotdog.jpeg,but return == APP == [xxx] [error] jpeg is invalid.
make run-api-wasi-socket-rs error log:
== APP == [2021-12-29 11:44:31.136] [error] instantiation failed: incompatible import type, Code: 0x61
== APP == [2021-12-29 11:44:31.136] [error] Mismatched function type. Expected: FuncType {params{i32 , i32 , i32} returns{i32}} , Got: FuncType {params{i32 , i32} returns{i32}}
== APP == [2021-12-29 11:44:31.136] [error] When linking module: "wasi_snapshot_preview1" , function name: "sock_accept"
== APP == [2021-12-29 11:44:31.136] [error] At AST node: import description
== APP == [2021-12-29 11:44:31.136] [error] At AST node: import section
== APP == [2021-12-29 11:44:31.136] [error] At AST node: module
The WasmEdge GO SDK allows developers to register host functions to the runtime, and create a customized version of WasmEdge that includes the host functions.
We should add Dapr GO SDK functions into a customized version of WasmEdge.
We should then create Rust APIs for those Dapr host functions so that WasmEdge app developers can use them.
http://23.100.38.125/static/home.html
Didn't seem to load for me. ๐ค
The current example uses wasm-bindgen
to pass call parameters from the GO app to the WASM function. However, wasm-bindgen
does not work with the Rust WASI target since Rust version 1.51. We now have a better solution for bindgen since WasmEdge 0.9.0. It is called wasmedge-bindgen
:
https://wasmedge.org/book/en/embed/go/function.html
Can we refactor the GO host example to use wasmedge-bindgen
?
I replace the web-port imageHandler func with the following code, to make it easier to observe(making more requests on one click). The memory usage of image-api-go is keeping growing when click classify.
type mock struct {}
func (m *mock)WriteHeader(statusCode int) {
}
func (m *mock)Header() http.Header {
return nil
}
func (m *mock)Write(b []byte) (int, error) {
return len(b), nil
}
func imageHandler(w http.ResponseWriter, r *http.Request) {
println("imageHandler ....")
body, err := ioutil.ReadAll(r.Body)
if err != nil {
println("error: ", err.Error())
panic(err)
}
api := r.Header.Get("api")
if api == "go" {
daprClientSend(body, w)
for i:=0;i<10;i++ {
go func() {
for i:=0;i<10;i++ {
daprClientSend(body, &mock{})
}
}()
}
} else {
httpClientSend(body, w)
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.