Basic Example

Source code: https://github.com/yomorun/yomo/tree/master/example/0-basic

This example represents how YoMo works with the mock data of sound sensor.

Code structure

  • source: Mocking data of a Sound Sensor.
  • sfn: Detecting noise pollution in real-time.
  • zipper: Orchestrate a workflow that receives the data from source, stream computing in stream-fn.

Prepare

Install YoMo CLI

$ curl -fsSL "https://get.yomo.run" | sh

  ==> Resolved version latest to v1.1.1
  ==> Downloading asset for darwin arm64
  ==> Permissions required for installation to /usr/local/bin
Password:
  ==> Installation complete

Or build from source

$ go install github.com/yomorun/cli/yomo@latest
$ yomo version
YoMo CLI Version: v0.1.8

Option 1: Auto Run

task run

Option 2: Manual

Run zipper

yomo serve -c ./workflow.yaml

Using config file: ./workflow.yaml
2021/11/11 16:09:54 [yomo:zipper] [AddWorkflow] 0, Noise
ℹ️   Running YoMo-Zipper...
2021/11/11 16:09:54 [yomo:zipper] Listening SIGTERM/SIGINT...
2021/11/11 16:09:54 [core:server](name:Service) Listening on: 127.0.0.1:9000, QUIC: [v1 draft-29]

yomo serve -c ./workflow.yaml

Using config file: ./workflow.yaml
ℹ️   Running YoMo-Zipper...
2022-03-18 10:21:05.820 [yomo:zipper] Listening SIGUSR1, SIGUSR2, SIGTERM/SIGINT...
2022-03-18 10:21:05.829 [core:server][Service] Listening on: 127.0.0.1:9000, MODE: DEVELOPMENT, QUIC: [v1 draft-29], AUTH: [None]

Run stream-function

go run ./sfn/main.go

2021/11/11 16:11:05 [core:client] use credential: [None]
2021/11/11 16:11:05 [core:client] ❤️  [Noise] is connected to YoMo-Zipper localhost:9000

Run yomo-source

go run ./source/main.go

2021/11/11 16:12:01 [core:client] use credential: [None]
2021/11/11 16:12:01 [core:client] ❤️  [yomo-source] is connected to YoMo-Zipper localhost:9000
2021/11/11 16:12:01 [source] ✅ Emit {192.13399 1636618321242 localhost} to YoMo-Zipper
2021/11/11 16:12:01 [source] ✅ Emit {132.86566 1636618321547 localhost} to YoMo-Zipper
2021/11/11 16:12:01 [source] ✅ Emit {199.17604 1636618321851 localhost} to YoMo-Zipper

Results

stream-function

The terminal of stream-function will print the real-time sound value.

2021/11/11 16:12:01 >> [sfn] got tag=0x33, data={ 0x1.80449ap+07  0x17d0e0dbd5a 0x6c 0x6f 0x63 0x61 0x6c 0x68 0x6f 0x73 0x74}
2021/11/11 16:12:01 >> [sfn] got tag=0x33, data={ 0x1.09bb38p+07  0x17d0e0dbe8b 0x6c 0x6f 0x63 0x61 0x6c 0x68 0x6f 0x73 0x74}
2021/11/11 16:12:01 >> [sfn] got tag=0x33, data={ 0x1.8e5a22p+07  0x17d0e0dbfbb 0x6c 0x6f 0x63 0x61 0x6c 0x68 0x6f 0x73 0x74}
Edit this page on GitHub Updated at Mon, Aug 1, 2022