Skip to content

Commit

Permalink
Fix TMClient.IsTimeoutError so that it doesn't always return true
Browse files Browse the repository at this point in the history
  • Loading branch information
aaijazi committed Feb 6, 2015
1 parent aae5e95 commit f30845c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions go/vt/tabletmanager/gorpctmclient/gorpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
"golang.org/x/net/context"
)

type timeoutError error
type timeoutError struct {
error
}

func init() {
tmclient.RegisterTabletManagerClientFactory("bson", func() tmclient.TabletManagerClient {
Expand All @@ -41,7 +43,7 @@ func (client *GoRPCTabletManagerClient) rpcCallTablet(ctx context.Context, table
if ok {
connectTimeout = deadline.Sub(time.Now())
if connectTimeout < 0 {
return timeoutError(fmt.Errorf("timeout connecting to TabletManager.%v on %v", name, tablet.Alias))
return timeoutError{fmt.Errorf("timeout connecting to TabletManager.%v on %v", name, tablet.Alias)}
}
}
rpcClient, err := bsonrpc.DialHTTP("tcp", tablet.Addr(), connectTimeout, nil)
Expand All @@ -55,7 +57,7 @@ func (client *GoRPCTabletManagerClient) rpcCallTablet(ctx context.Context, table
select {
case <-ctx.Done():
if ctx.Err() == context.DeadlineExceeded {
return timeoutError(fmt.Errorf("timeout waiting for TabletManager.%v to %v", name, tablet.Alias))
return timeoutError{fmt.Errorf("timeout waiting for TabletManager.%v to %v", name, tablet.Alias)}
}
return fmt.Errorf("interrupted waiting for TabletManager.%v to %v", name, tablet.Alias)
case <-call.Done:
Expand Down Expand Up @@ -156,7 +158,7 @@ func (client *GoRPCTabletManagerClient) HealthStream(ctx context.Context, tablet
if ok {
connectTimeout = deadline.Sub(time.Now())
if connectTimeout < 0 {
return nil, nil, timeoutError(fmt.Errorf("timeout connecting to TabletManager.HealthStream on %v", tablet.Alias))
return nil, nil, timeoutError{fmt.Errorf("timeout connecting to TabletManager.HealthStream on %v", tablet.Alias)}
}
}
rpcClient, err := bsonrpc.DialHTTP("tcp", tablet.Addr(), connectTimeout, nil)
Expand Down Expand Up @@ -390,7 +392,7 @@ func (client *GoRPCTabletManagerClient) Snapshot(ctx context.Context, tablet *to
if ok {
connectTimeout = deadline.Sub(time.Now())
if connectTimeout < 0 {
return nil, nil, timeoutError(fmt.Errorf("timeout connecting to TabletManager.Snapshot on %v", tablet.Alias))
return nil, nil, timeoutError{fmt.Errorf("timeout connecting to TabletManager.Snapshot on %v", tablet.Alias)}
}
}
rpcClient, err := bsonrpc.DialHTTP("tcp", tablet.Addr(), connectTimeout, nil)
Expand Down Expand Up @@ -454,7 +456,7 @@ func (client *GoRPCTabletManagerClient) Restore(ctx context.Context, tablet *top
if ok {
connectTimeout = deadline.Sub(time.Now())
if connectTimeout < 0 {
return nil, nil, timeoutError(fmt.Errorf("timeout connecting to TabletManager.Restore on %v", tablet.Alias))
return nil, nil, timeoutError{fmt.Errorf("timeout connecting to TabletManager.Restore on %v", tablet.Alias)}
}
}
rpcClient, err := bsonrpc.DialHTTP("tcp", tablet.Addr(), connectTimeout, nil)
Expand Down

0 comments on commit f30845c

Please sign in to comment.