Skip to content

Commit

Permalink
remove comments, and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dxyinme committed Dec 31, 2023
1 parent 85fa0aa commit 49b2af8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 41 deletions.
29 changes: 0 additions & 29 deletions driver/etcddriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,35 +149,6 @@ func (e *EtcdDriver) startHeartBeat(ctx context.Context) {
e.logger.Errorf("keep alive error, %v", err)
return
}
// for {
// select {
// case <-e.ctx.Done():
// {
// e.logger.Infof("driver stopped")
// return
// }
// case _, ok := <-leaseCh:
// {
// // if lease timeout, goto top of
// // this function to keepalive
// if !ok {
// goto label
// }
// }
// case <-time.After(etcdBusinessTimeout):
// {
// e.logger.Errorf("ectd cli keepalive timeout")
// return
// }
// case <-time.After(time.Duration(e.lease) * (time.Second) / 2):
// {
// // if near to nodes time,
// // renew the lease
// e.logger.Errorf("renew lease due to heartbeat ended.")
// goto label
// }
// }
// }
}

func (e *EtcdDriver) keepHeartBeat() {
Expand Down
6 changes: 2 additions & 4 deletions e2e/etcddriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ func TestEtcdDriver_Stop(t *testing.T) {
DialTimeout: 3 * time.Second,
})
drv2.Init(t.Name(), driver.NewTimeoutOption(5*time.Second), driver.NewLoggerOption(dlog.NewLoggerForTest(t)))
err = drv2.Start(context.Background())
require.Nil(t, err)
require.Nil(t, drv2.Start(context.Background()))
require.Nil(t, drv1.Start(context.Background()))

err = drv1.Start(context.Background())
require.Nil(t, err)
<-time.After(3 * time.Second)
nodes, err = drv1.GetNodes(context.Background())
require.Nil(t, err)
Expand Down
9 changes: 5 additions & 4 deletions e2e/redisdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ func TestRedisDriver_Stop(t *testing.T) {
drv2.Init(t.Name(),
driver.NewTimeoutOption(5*time.Second),
driver.NewLoggerOption(dlog.NewLoggerForTest(t)))
err = drv2.Start(context.Background())
require.Nil(t, err)

err = drv1.Start(context.Background())
require.Nil(t, err)
require.Nil(t, drv2.Start(context.Background()))
require.Nil(t, drv1.Start(context.Background()))

nodes, err = drv1.GetNodes(context.Background())
require.Nil(t, err)
Expand All @@ -87,6 +85,9 @@ func TestRedisDriver_Stop(t *testing.T) {
nodes, err = drv2.GetNodes(context.Background())
require.Nil(t, err)
require.Len(t, nodes, 2)
nodes, err = drv1.GetNodes(context.Background())
require.Nil(t, err)
require.Len(t, nodes, 2)

drv2.Stop(context.Background())
drv1.Stop(context.Background())
Expand Down
9 changes: 5 additions & 4 deletions e2e/rediszsetdriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ func TestRedisZSetDriver_Stop(t *testing.T) {
drv2.Init(t.Name(),
driver.NewTimeoutOption(5*time.Second),
driver.NewLoggerOption(dlog.NewLoggerForTest(t)))
err = drv2.Start(context.Background())
require.Nil(t, err)

err = drv1.Start(context.Background())
require.Nil(t, err)
require.Nil(t, drv2.Start(context.Background()))
require.Nil(t, drv1.Start(context.Background()))

nodes, err = drv1.GetNodes(context.Background())
require.Nil(t, err)
Expand All @@ -85,6 +83,9 @@ func TestRedisZSetDriver_Stop(t *testing.T) {
nodes, err = drv2.GetNodes(context.Background())
require.Nil(t, err)
require.Len(t, nodes, 2)
nodes, err = drv1.GetNodes(context.Background())
require.Nil(t, err)
require.Len(t, nodes, 2)

drv2.Stop(context.Background())
drv1.Stop(context.Background())
Expand Down

0 comments on commit 49b2af8

Please sign in to comment.