You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
package producer
|
|
|
|
import (
|
|
"context"
|
|
"joybuywork/internal/consts"
|
|
"joybuywork/internal/service/queue/types"
|
|
|
|
"gits.branchcn.com/backend/microcode/plugins/derivative/delay"
|
|
"go-micro.dev/v4/metadata"
|
|
)
|
|
|
|
// RewardPushPub 奖励推送延时对列
|
|
func RewardPushPub(ctx context.Context, sec int, data types.DelayCommonRewardPush) (msgId string, err error) {
|
|
var opts = []delay.PushOption{
|
|
delay.UseType(types.CommonRewardPush),
|
|
}
|
|
|
|
if tradeId, ok := metadata.Get(ctx, consts.TraceIdKey); ok && tradeId != "" {
|
|
opts = append(opts, delay.UseAppId(tradeId))
|
|
}
|
|
|
|
return DelayCommon.Push(sec, data, opts...)
|
|
}
|
|
|
|
// GlobalRewardPushPub 全局奖励推送延时对列
|
|
func GlobalRewardPushPub(ctx context.Context, sec int, data types.DelayCommonGlobalRewardPush) (msgId string, err error) {
|
|
var opts = []delay.PushOption{
|
|
delay.UseType(types.CommonGlobalRewardPush),
|
|
}
|
|
|
|
if tradeId, ok := metadata.Get(ctx, consts.TraceIdKey); ok && tradeId != "" {
|
|
opts = append(opts, delay.UseAppId(tradeId))
|
|
}
|
|
|
|
return DelayCommon.Push(sec, data, opts...)
|
|
}
|
|
|
|
// CoinExpired 金币过期推送延时对列
|
|
func CoinExpired(ctx context.Context, sec int, data types.DelayCommonCoinExpired) (msgId string, err error) {
|
|
var opts = []delay.PushOption{
|
|
delay.UseType(types.CommonCoinExpired),
|
|
}
|
|
|
|
if tradeId, ok := metadata.Get(ctx, consts.TraceIdKey); ok && tradeId != "" {
|
|
opts = append(opts, delay.UseAppId(tradeId))
|
|
}
|
|
|
|
return DelayCommon.Push(sec, data, opts...)
|
|
}
|
|
|
|
// CheckRewardPush 金币过期推送延时对列
|
|
func CheckRewardPush(ctx context.Context, sec int, data types.DelayCommonCheckRewardPush) (msgId string, err error) {
|
|
var opts = []delay.PushOption{
|
|
delay.UseType(types.CommonCheckRewardPush),
|
|
}
|
|
|
|
if tradeId, ok := metadata.Get(ctx, consts.TraceIdKey); ok && tradeId != "" {
|
|
opts = append(opts, delay.UseAppId(tradeId))
|
|
}
|
|
|
|
return DelayCommon.Push(sec, data, opts...)
|
|
}
|