36 lines
614 B
Go
36 lines
614 B
Go
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
|
|
}
|