Skip to content

Commit

Permalink
Merge pull request #16 from Ccheers/dev
Browse files Browse the repository at this point in the history
feat(xmsgbus): 修复蠊 msgbus 自带 * 的问题
  • Loading branch information
Ccheers authored Jul 24, 2024
2 parents d94ad85 + 10d54f5 commit 354b8f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.21.x, 1.22.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
6 changes: 5 additions & 1 deletion xmsgbus/impl/redis/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package redis

import (
"context"
"strings"
"time"

"github.com/ccheers/xpkg/xmsgbus"
Expand All @@ -21,7 +22,10 @@ func (x *SharedStorage) SetEx(ctx context.Context, key string, value interface{}
}

func (x *SharedStorage) Keys(ctx context.Context, prefix string) ([]string, error) {
return x.client.Keys(ctx, prefix+"*").Result()
if !strings.HasSuffix(prefix, "*") {
prefix += "*"
}
return x.client.Keys(ctx, prefix).Result()
}

func (x *SharedStorage) Del(ctx context.Context, key string) error {
Expand Down
2 changes: 1 addition & 1 deletion xmsgbus/topicmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (x *TopicManager) check(ctx context.Context, topic string) {
}

for _, channel := range channels {
results, err := x.storage.Keys(ctx, x.subKeyPrefix(topic, channel)+"*")
results, err := x.storage.Keys(ctx, x.subKeyPrefix(topic, channel))
if err != nil {
_ = xlogger.DefaultLogger.Log(xlogger.LevelError,
"err", err,
Expand Down

0 comments on commit 354b8f5

Please sign in to comment.