yomo dev
Developer always want elligant and fast development experience. yomo dev
command is a shortcut for yomo run -z tap.yomo.dev:9140 -n yomo-app-demo
command. It will connect to the development zipper server and set the StreamFunction name as yomo-app-demo
which zipper needed.
If you do not want to setup your zipper service but want to try YoMo quickly, you can use yomo dev
command to run your StreamFunction.
Usage
yomo dev [flags] [/path/to/wasm]
Flags
-f, --filename
- The wasm file compiled from StreamFunction.-m, --modfile
- Custom thego.mod
file.
Example
ᐅ yomo init try_yomo && cd try_yomo
ᐅ yomo dev
ℹ️ YoMo Stream Function file: app.go
⌛ Create YoMo Stream Function instance...
⌛ YoMo Stream Function building...
✅ Success! YoMo Stream Function build.
ℹ️ YoMo Stream Function is running...
ℹ️ Run: /Users/fanweixiao/tmp/accumulator-func/sfn.yomo
time=2023-04-16T20:50:28.789+08:00 level=INFO msg="use credential" component="Stream Function" client_id=OW-1tB9X0AT7EivDwmM5n client_name=yomo-app-demo credential_name=none
time=2023-04-16T20:50:29.417+08:00 level=INFO msg="connected to zipper" component="Stream Function" client_id=OW-1tB9X0AT7EivDwmM5n client_name=yomo-app-demo zipper_addr=tap.yomo.dev:9140
sfn received 58 bytes
sfn received 58 bytes
sfn received 59 bytes
sfn received 59 bytes
sfn received 59 bytes
sfn received 59 bytes
sfn received 59 bytes
sfn received 58 bytes
sfn received 59 bytes
^C
Press Ctrl-C
to terminate it.
tap.yomo.dev:9140
This is a public zipper service for development, provided by YoMo Community. You can use it to test your StreamFunction. It is a free service, but we do not guarantee the stability of the service. If you want to use it in production, please deploy your own zipper service.
when your stream function connected to tap.yomo.dev:9140
, after authentication, this zipper services will send ingress data to your stream function every 200ms, every chunk is a string of serialized JSON object, it looks like:
{"noise":34.756016,"time":1681651543820,"from":"localhost"}
Let's do some changes on app.go
to inspect the data
chunck:
package main
import (
"fmt"
"strings"
"github.com/yomorun/yomo/core/frame"
)
// Handler will handle the raw data
func Handler(data []byte) (frame.Tag, []byte) {
fmt.Printf("sfn received %d bytes: %s\n", len(data), string(data))
output := strings.ToUpper(string(data))
return frame.Tag(0x34), []byte(output)
}
func DataTags() []frame.Tag {
return []frame.Tag{0x33}
}
Then, execute yomo dev
again:
ᐅ yomo dev app.go
ℹ️ YoMo Stream Function file: app.go
⌛ Create YoMo Stream Function instance...
⌛ YoMo Stream Function building...
✅ Success! YoMo Stream Function build.
ℹ️ YoMo Stream Function is running...
ℹ️ Run: /Users/fanweixiao/tmp/accumulator-func/sfn.yomo
time=2023-04-16T21:25:42.149+08:00 level=INFO msg="use credential" component="Stream Function" client_id=aQkfLU0H5c_oenFvNFeLK client_name=yomo-app-demo credential_name=none
time=2023-04-16T21:25:42.768+08:00 level=INFO msg="connected to zipper" component="Stream Function" client_id=aQkfLU0H5c_oenFvNFeLK client_name=yomo-app-demo zipper_addr=tap.yomo.dev:9140
sfn received 59 bytes: {"noise":159.12856,"time":1681651543015,"from":"localhost"}
sfn received 59 bytes: {"noise":16.928843,"time":1681651543116,"from":"localhost"}
sfn received 59 bytes: {"noise":157.44992,"time":1681651543216,"from":"localhost"}
sfn received 58 bytes: {"noise":2.337227,"time":1681651543317,"from":"localhost"}
sfn received 59 bytes: {"noise":192.65875,"time":1681651543417,"from":"localhost"}
sfn received 59 bytes: {"noise":60.196793,"time":1681651543518,"from":"localhost"}
sfn received 59 bytes: {"noise":29.519758,"time":1681651543618,"from":"localhost"}
sfn received 58 bytes: {"noise":46.60378,"time":1681651543719,"from":"localhost"}
sfn received 59 bytes: {"noise":34.756016,"time":1681651543820,"from":"localhost"}
sfn received 59 bytes: {"noise":25.069178,"time":1681651543920,"from":"localhost"}
^C
WebAssebly Support
You can also use yomo dev
to run your WebAssembly StreamFunction, next, let's build app.go to WebAssebly.