func (client *GoRpcTabletManagerConn) rpcCallTablet(tablet *topo.TabletInfo, name string, args, reply interface{}, waitTime time.Duration) error { // create the RPC client, using waitTime as the connect // timeout, and starting the overall timeout as well timer := time.After(waitTime) rpcClient, err := bsonrpc.DialHTTP("tcp", tablet.GetAddr(), waitTime, nil) if err != nil { return fmt.Errorf("RPC error for %v: %v", tablet.Alias, err.Error()) } defer rpcClient.Close() // do the call in the remaining time call := rpcClient.Go("TabletManager."+name, args, reply, nil) select { case <-timer: return fmt.Errorf("Timeout waiting for TabletManager.%v to %v", name, tablet.Alias) case <-call.Done: if call.Error != nil { return fmt.Errorf("Remote error for %v: %v", tablet.Alias, call.Error.Error()) } else { return nil } } }