wangjian
1 year ago
9 changed files with 78 additions and 23 deletions
@ -1,5 +1,6 @@
|
||||
name: mq-1 |
||||
host: 0.0.0.0 |
||||
port: 27188 |
||||
port: 27187 |
||||
functions: |
||||
- name: echo-sf |
||||
- name: capture-agent |
||||
|
@ -0,0 +1,35 @@
|
||||
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 |
||||
} |
Loading…
Reference in new issue