-
Notifications
You must be signed in to change notification settings - Fork 701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add redis cluster #938
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## master #938 +/- ##
===========================================
- Coverage 53.16% 33.01% -20.15%
===========================================
Files 202 162 -40
Lines 11335 8538 -2797
===========================================
- Hits 6026 2819 -3207
- Misses 4857 5486 +629
+ Partials 452 233 -219
|
建议新增一种cluster类型,和stub类型同级 |
@city55238 我理解的,是不是把cluster和stub client完全独立会更好呢? |
@city55238 可以参考现有的redis单测,加下cluster的测试用例 |
已经补充过了,但是nomal start的样例需要你那边有一个集群模式的redis,不然单测跑不过 |
"github.com/samber/lo" | ||
"go.uber.org/zap" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里如果用组合会不会更简单些
type ClusterClient struct {
*redis.ClusterClient
config *Config
}
pkg/client/redis/cluster.go
Outdated
config *Config | ||
} | ||
|
||
func (ins *ClusterClient) CmdOnCluster() *redis.ClusterClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是用组合的话,这个方法就不需要了
pkg/client/redis/cluster.go
Outdated
) | ||
|
||
type ClusterClient struct { | ||
cluster *redis.ClusterClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一行也可以去掉了
LGTM |
Describe what this PR does / why we need it
redis支持集群模式
Does this pull request fix one issue?
feat
Describe how you did it
在原生redis-go sdk的基础上接入cluster,修改cluster redis配置的加载方式
cluster配置支持云厂商连接:"r-bp1zxszhcgatnx****.redis.rds.aliyuncs.com:6379"
也支持自定义node集群连接: ["127.0.0.1:6379","127.0.0.1:6370","127.0.0.1:6371"]
配置示例:
[jupiter.redis.exampleserver]
[jupiter.redis.exampleserver.cluster]
debug = false
maxIdle = 10
maxActive = 50
dialTimeout = "2s"
readTimeout = "2s"
idleTimeout = "60s"
enableAccessLog = false
addr = ["r-bp1zxszhcgatnx****.redis.rds.aliyuncs.com:6379"] # ["127.0.0.1:6379","127.0.0.1:6370","127.0.0.1:6371"]
username = "root"
password = "xxxxxx"
Describe how to verify it
Special notes for reviews