Skip to content

Commit

Permalink
Tweak auto-reloads
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jun 29, 2020
1 parent 0ffefcd commit 64995f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 2 additions & 8 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,15 +622,15 @@ func (c *clusterStateHolder) LazyReload(ctx context.Context) {
if err != nil {
return
}
time.Sleep(100 * time.Millisecond)
time.Sleep(250 * time.Millisecond)
}()
}

func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
v := c.state.Load()
if v != nil {
state := v.(*clusterState)
if time.Since(state.createdAt) > time.Minute {
if time.Since(state.createdAt) > 10*time.Second {
c.LazyReload(ctx)
}
return state, nil
Expand Down Expand Up @@ -780,9 +780,6 @@ func (c *ClusterClient) _process(ctx context.Context, cmd Cmder) error {
if lastErr == nil {
return nil
}
if lastErr != Nil {
c.state.LazyReload(ctx)
}
if lastErr == pool.ErrClosed || isReadOnlyError(lastErr) {
node = nil
continue
Expand Down Expand Up @@ -1431,9 +1428,6 @@ func (c *ClusterClient) Watch(ctx context.Context, fn func(*Tx) error, keys ...s
if err == nil {
break
}
if err != Nil {
c.state.LazyReload(ctx)
}

moved, ask, addr := isMovedError(err)
if moved || ask {
Expand Down
4 changes: 2 additions & 2 deletions internal/hashtag/hashtag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ var _ = Describe("HashSlot", func() {
{"{}foo", 9500},
{"foo{}", 5542},
{"foo{}{bar}", 8363},
{"", 10503},
{"", 5176},
{"", 7404},
{"", 4403},
{string([]byte{83, 153, 134, 118, 229, 214, 244, 75, 140, 37, 215, 215}), 5463},
}
// Empty keys receive random slot.
Expand Down

0 comments on commit 64995f9

Please sign in to comment.