vitess.io/vitess@v0.16.2/go/vt/vttablet/tabletmanager/vreplication/queryhistory/history.go (about)

     1  package queryhistory
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  )
     7  
     8  // History represents an actual sequence of SQL statements.
     9  type History []string
    10  
    11  // At returns the query in the history at the given index. Returns an error if
    12  // the index is out-of-bounds.
    13  func (h History) At(index int) (string, error) {
    14  	if len(h) <= index || index < 0 {
    15  		return "", fmt.Errorf("index out of range: %d", index)
    16  	}
    17  
    18  	return h[index], nil
    19  }
    20  
    21  func (h History) String() string {
    22  	return strings.Join(h, "\n")
    23  }