28 lines
725 B
Go
28 lines
725 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/rabbitmq/amqp091-go"
|
|
"samba/pkg/log"
|
|
"samba/pkg/servername"
|
|
"samba/pkg/service"
|
|
"samba/proto"
|
|
"samba/util/routingKey"
|
|
"samba/util/util"
|
|
)
|
|
|
|
var MsgHandler = map[string]MessageHandler{
|
|
proto.NtfClickHouseSqlId: onAddClickHouseLog,
|
|
proto.ReqInsertClickHouseId: onInsertClickHouse,
|
|
proto.ReqGetOnlineFlowId: onReqGetOnlineFlow,
|
|
}
|
|
|
|
type MessageHandler func(d *amqp091.Delivery, msg map[string]interface{})
|
|
|
|
func RegisterMsgHandler(s service.IService, childId int) bool {
|
|
if err := s.QueueBind(gDBServices.QueueName(childId), routingKey.ClickHouseKey(int64(childId)), util.Direct(servername.ClickHouse)); err != nil {
|
|
log.Error(err.Error())
|
|
return false
|
|
}
|
|
return true
|
|
}
|