发布时间:2026-07-23阅读(1)
《开源精选》是我们分享Github、Gitee等开源社区中优质项目的栏目,包括技术、学习、实用与各种有趣的内容。本期推荐的是一个基于GO开发的低延时流式边缘计算框架——yomo。

YoMo 是一个为边缘计算领域打造的低时延流式数据处理框架,基于 QUIC 协议通讯,以 Functional Reactive Programming 为编程范式,构建可靠、安全的低时延实时计算应用,挖掘 5G 潜力,释放实时计算价值。
特性1 先决条件
确保已安装 Go 编译运行环境。
2 安装 CLI
Binary(推荐):
$ curl -fsSL "https://bina.egoist.sh/yomorun/cli?name=yomo" | sh
或者从源代码编译:
$ go install github.com/yomorun/cli/yomo@latest
验证 CLI 是否成功安装:
$ yomo -VYoMo CLI version: v0.1.8
3 创建一个 Serverless 应用
$ yomo init yomo-app-demo⌛ Initializing the Serverless app...✅ Congratulations! You have initialized the serverless function successfully.ℹ️ You can enjoy the YoMo Serverless via the command: ℹ️ DEV: yomo dev -n Noise yomo-app-demo/app.goℹ️ PROD: First run source application, eg: go run example/source/main.go Second: yomo run -n yomo-app-demo yomo-app-demo/app.go$ cd yomo-app-demo
YoMo CLI 会自动创建带有以下内容的 app.go 文件:
package mainimport ( "context" "encoding/json" "fmt" "time" "github.com/yomorun/yomo/rx")// NoiseData represents the structure of datatype NoiseData struct { Noise float32 `json:"noise"` // Noise value Time int64 `json:"time"` // Timestamp (ms) From string `json:"from"` // Source IP}var echo = func(_ context.Context, i interface{}) (interface{}, error) { value := i.(*NoiseData) value.Noise = value.Noise / 10 rightNow := time.Now().UnixNano() / int64(time.Millisecond) fmt.Println(fmt.Sprintf("[%s] %d > value: %f ⚡️=%dms", value.From, value.Time, value.Noise, rightNow-value.Time)) return value.Noise, nil}// Handler will handle data in Rx wayfunc Handler(rxstream rx.Stream) rx.Stream { stream := rxstream. Unmarshal(json.Unmarshal, func() interface{} { return &NoiseData{} }). Debounce(50). Map(echo). StdOut() return stream}func DataTags() []byte { return []byte{0x33}}
4 编译并运行
从 terminal 运行 yomo dev,可以看到:
$ yomo devℹ️ YoMo serverless function file: app.go⌛ Create YoMo serverless instance...⌛ YoMo serverless function building...✅ Success! YoMo serverless function build.ℹ️ YoMo serverless function is running...ℹ️ Run: /Users/xiaojianhong/Downloads/yomo-app-demo/sl.yomo2021/06/07 12:00:06 Connecting to zipper dev.yomo.run:9000 ...2021/06/07 12:00:07 ✅ Connected to zipper dev.yomo.run:9000[10.10.79.50] 1623038407236 > value: 1.919251 ⚡️=-25ms[StdOut]: 1.9192511[10.10.79.50] 1623038407336 > value: 11.370256 ⚡️=-25ms[StdOut]: 11.370256[10.10.79.50] 1623038407436 > value: 8.672209 ⚡️=-25ms[StdOut]: 8.672209[10.10.79.50] 1623038407536 > value: 4.826996 ⚡️=-25ms[StdOut]: 4.826996[10.10.79.50] 1623038407636 > value: 16.201773 ⚡️=-25ms[StdOut]: 16.201773[10.10.79.50] 1623038407737 > value: 13.875483 ⚡️=-26ms[StdOut]: 13.875483

—END—
开源协议:Apache2.0
开源地址:https://github.com/yomorun/yomo
Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图