Skip to content
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

slaves/dns: 集成测试添加 #156

Closed
wants to merge 0 commits into from
Closed

slaves/dns: 集成测试添加 #156

wants to merge 0 commits into from

Conversation

juniaoshaonian
Copy link
Collaborator

No description provided.

Copy link
Contributor

@flycash flycash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码冲突了!

slaves := make([]*sql.DB, 0, len(s.slavedsns))
for _, slavedsn := range s.slavedsns {
slave, err := sql.Open(s.driver, slavedsn)
if s.geterName == "roundrobin" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里最好是初始化这个 MasterSlaveSuite 的地方直接指定好 Slaves 的实现,而不是这么分发

@@ -87,6 +87,7 @@ func TestMasterSlaveDelete(t *testing.T) {
driver: "mysql",
masterdsn: "root:root@tcp(localhost:13307)/integration_test",
slavedsns: []string{"root:root@tcp(localhost:13308)/integration_test"},
geterName: "roundrobin",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

就是你这里直接传入 Slaves 实例,而不是这样一个 getter name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那么前面的 slavdsns 就可能用不着了

ctx, cancel := context.WithTimeout(context.Background(), s.timeout)
err := s.getSlaves(ctx)
cancel()
// 尽最大努力重试,拿到dns的响应
if err != nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在 continue 之前打印一下这个 err 吧,你可以考虑引入一个 log func(msg, args...) 啥的字段,也可以考虑直接用 log.Println。大体上我认为需要告诉一下用户,但是怎么告诉用户就不是特别重要了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants