39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
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")
|
||
}
|
||
})
|
||
}
|
||
}
|