-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
yomo-plugin的对codec数据的消费方式如下:https://github.com/yomorun/yomo-echo-plugin#echogo
package main
import (
"github.com/yomorun/yomo/pkg/env"
"github.com/yomorun/yomo/pkg/yomo"
)
func main() {
endpoint := env.GetString("YOMO_PLUGIN_ENDPOINT", "localhost:4241")
yomo.RunDev(&EchoPlugin{}, endpoint)
}
// EchoPlugin is a demo for echo
type EchoPlugin struct{}
// Handle data-------->(3) 在这里,value就是payload内容
func (p *EchoPlugin) Handle(value interface{}) (interface{}, error) {
return value.(string) + "-new", nil
}
// Observed key -------->(1) 在这里,Observed返回该plugin要关注的Key(即Tag,比如0x23这样的SeqID)
func (p EchoPlugin) Observed() string {
return "name"
}
// Mold describe the struct of `Observed` value-------->(2) 在这里,是使用codec的decode的过程
func (p EchoPlugin) Mold() interface{} {
return ""
}
// Name this plugin
func (p *EchoPlugin) Name() string {
return "EchoPlugin"
}
Metadata
Metadata
Assignees
Labels
No labels