hpds_node/example/multi-mq/stream_process_ca/main.go

36 lines
614 B
Go
Raw Permalink Normal View History

2023-03-24 08:49:01 +08:00
package main
import (
"git.hpds.cc/pavement/hpds_node"
"log"
"os"
)
func main() {
sf := hpds_node.NewStreamFunction(
"capture-agent",
hpds_node.WithMqAddr("localhost:27187"),
hpds_node.WithObserveDataTags(18),
hpds_node.WithCredential("06d36c6f5705507dae778fdce90d0767"),
)
defer sf.Close()
// set handler
sf.SetHandler(handler)
// start
err := sf.Connect()
if err != nil {
log.Fatalf("[sf] connect err=%v", err)
os.Exit(1)
}
select {}
}
func handler(data []byte) (byte, []byte) {
val := string(data)
log.Printf(">> [streamFunction] got tag=0x12, data=%s", val)
return 0x0, nil
}