Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions go/connection-refresh/btrefresh/bigtable_rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,25 @@ func NewRotatingTable(dialer BtDialer, table string, refresh time.Duration) (*Ro
rt := &RotatingTable{tbl, client, ticker, errors}
go func() {
for range ticker.C {
// Close the old client after waiting a bit
go func() {
oldC := rt.client
time.Sleep(lameduckTime)
oldC.Close()
}()
// save the old client so that we can close it
oldC := rt.client

client, err := dialer()
if err != nil {
errors <- err
continue
}
tbl := client.Open(table)
warmTable(tbl)

rt.client = client
rt.Table = tbl

// Close the old client after waiting a bit
go func() {
time.Sleep(lameduckTime)
oldC.Close()
}()
}
}()
return rt, nil
Expand Down