// markDown closes conn and temporarily marks the associated // end point as unusable. func (sdc *ShardConn) markDown(conn tabletconn.TabletConn, reason string) { sdc.mu.Lock() defer sdc.mu.Unlock() if conn != sdc.conn { return } sdc.balancer.MarkDown(conn.EndPoint().Uid, reason) // Launch as goroutine so we don't block go sdc.conn.Close() sdc.conn = nil }
// StreamExecute executes a streaming query on vttablet. The retry rules are the same as Execute. func (sdc *ShardConn) StreamExecute(ctx context.Context, query string, bindVars map[string]interface{}, transactionID int64) (<-chan *mproto.QueryResult, tabletconn.ErrFunc) { var usedConn tabletconn.TabletConn var erFunc tabletconn.ErrFunc var results <-chan *mproto.QueryResult err := sdc.withRetry(ctx, func(conn tabletconn.TabletConn) error { var err error results, erFunc, err = conn.StreamExecute(ctx, query, bindVars, transactionID) usedConn = conn return err }, transactionID, true) if err != nil { return results, func() error { return err } } inTransaction := (transactionID != 0) return results, func() error { return sdc.WrapError(erFunc(), usedConn.EndPoint(), inTransaction) } }