You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
package channel
|
|
|
|
import (
|
|
"context"
|
|
"git.oa00.com/supply-chain/service/client"
|
|
"github.com/smallnest/rpcx/share"
|
|
)
|
|
|
|
const (
|
|
MqSubscribeNameSkuPriceChange = "sku_price_change" // sku价格变动
|
|
MqSubscribeNameSkuChange = "sku_change" // sku信息变动
|
|
MqSubscribeNameOrderSplit = "order_split" // 订单拆单
|
|
MqSubscribeNameOrderLadingBill = "order_lading_bill" // 提单
|
|
MqSubscribeNameOrderStockOut = "order_stock_out" // 订单出库
|
|
MqSubscribeNameOrderFinish = "order_finish" // 订单完成
|
|
MqSubscribeNameOrderCancel = "order_cancel" // 订单取消
|
|
)
|
|
|
|
type mq struct {
|
|
}
|
|
type ArgsMqSubscribe struct {
|
|
Name string // 队列名称
|
|
AppKey string // 队列名称
|
|
}
|
|
|
|
// Subscribe @Title 订阅mq
|
|
func (m *mq) Subscribe(ctx context.Context, channelId string, args ArgsMqSubscribe) (err error) {
|
|
reply := 0
|
|
xClient, err := client.GetClient(m)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "Subscribe", args, &reply)
|
|
return
|
|
}
|
|
|
|
// SubscribeCancel @Title 订阅取消
|
|
func (m *mq) SubscribeCancel(ctx context.Context, channelId string, args ArgsMqSubscribe) (err error) {
|
|
reply := 0
|
|
xClient, err := client.GetClient(m)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(context.WithValue(ctx, share.ReqMetaDataKey, map[string]string{"channelId": channelId}), "SubscribeCancel", args, &reply)
|
|
return
|
|
}
|