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

36 lines
683 B
Go
Raw Permalink Normal View History

2022-10-12 11:55:36 +08:00
package main
import (
"git.hpds.cc/Component/network/log"
"git.hpds.cc/pavement/hpds_node"
"os"
)
func main() {
mq, err := hpds_node.NewMq("mq_1.yaml")
if err != nil {
panic(err)
}
2023-03-24 08:49:01 +08:00
mq.InitOptions(hpds_node.WithAuth("token", "06d36c6f5705507dae778fdce90d0767"))
defer func(mq hpds_node.MessageQueue) {
_ = mq.Close()
}(mq)
2022-10-12 11:55:36 +08:00
// add Downstream mq
2023-03-24 08:49:01 +08:00
_ = mq.AddDownstreamMq(hpds_node.NewDownstreamMq(
2022-10-12 11:55:36 +08:00
"mq-2",
hpds_node.WithMqAddr("localhost:27187"),
hpds_node.WithCredential("token:z2"),
))
// start mq service
log.Printf("Server has started!, pid: %d", os.Getpid())
go func() {
err := mq.ListenAndServe()
if err != nil {
panic(err)
}
}()
select {}
}