redis/redis_test.go
2024-05-28 15:11:20 +08:00

39 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package redis
import (
"fmt"
"log"
"testing"
"qoobing.com/gomod/redis/sentinel"
"qoobing.com/gomod/redis/xstream"
)
func TestNewConsumer(t *testing.T) {
cfg := xstream.Config{
Group: "group_a",
Stream: "testxstream_queue",
Sentinel: sentinel.Config{
Debug: true, //调试开关会在日志打印REDIS语句)
MasterName: "walletmaster", //REDIS主名称一个哨兵集群可管理多个REDIS主从结构
Username: "web3wallet", //REDIS连接用户名
Password: "web3onthemoon@2023#dev", //REDIS连接用户密码
Sentinels: "sentinel-0.redis:5000", //哨兵节点列表,逗号分隔,一般配置三个
SentinelUsername: "sentinel", //哨兵节点连接用户名不填默认default
SentinelPassword: "password@mhxzkhl#dev", //哨兵节点连接密码,不填认为集群无密码
},
}
for i := 0; i < 15; i++ {
i := i
name := fmt.Sprintf("name-%d", i)
t.Run(name, func(t *testing.T) {
t.Parallel()
log.Println("name", name)
if r := xstream.NewReader(cfg); r == nil {
t.Error("create new reader failed")
}
})
}
}