upgrade: update wrapper
This commit is contained in:
@ -11,13 +11,15 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"git.zhangdeman.cn/zhangdeman/event/abstract"
|
||||
"git.zhangdeman.cn/zhangdeman/event/define"
|
||||
"git.zhangdeman.cn/zhangdeman/serialize"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper/op_string"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper/op_ternary"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -64,7 +66,7 @@ type RedisEventPubSub struct {
|
||||
//
|
||||
// Date : 10:58 2024/6/27
|
||||
func (r *RedisEventPubSub) SendEvent(ctx context.Context, eventData *define.EventData) (*define.SendResult, error) {
|
||||
partition := int(wrapper.String(eventData.Key).HashNumber().Value % uint64(r.pubSubConfig.PartitionNum))
|
||||
partition := int(op_string.HashNumber(eventData.Key).Value % uint64(r.pubSubConfig.PartitionNum))
|
||||
realTopic := fmt.Sprintf("%v_%v", r.pubSubConfig.Topic, partition)
|
||||
res := r.redisClient.Publish(ctx, realTopic, eventData)
|
||||
if nil == res {
|
||||
@ -75,7 +77,7 @@ func (r *RedisEventPubSub) SendEvent(ctx context.Context, eventData *define.Even
|
||||
Partition: partition,
|
||||
Topic: realTopic,
|
||||
IsSuccess: res.Err() == nil,
|
||||
FailReason: wrapper.TernaryOperator.String(res.Err() == nil, "success", wrapper.String(res.Err().Error())).Value(),
|
||||
FailReason: op_ternary.BaseType[string](res.Err() == nil, "success", res.Err().Error()),
|
||||
Extension: nil,
|
||||
}, res.Err()
|
||||
}
|
||||
|
Reference in New Issue
Block a user