Documentation ¶
Overview ¶
Package lib contains all types and functions for db-checker
Index ¶
- Variables
- func DiffPretty(a, b string) string
- func FindCheckInCheckResults(needle Check, list []CheckResult) int
- func ReportProblems(results []CheckResult) (int, string)
- func ResultInSlice(needle CheckResult, list []CheckResult) bool
- func ToTabString(values []string) string
- func WriteReport(results []CheckResult, f io.Writer) error
- func WriteReportFile(results []CheckResult, filePath string) error
- type Check
- type CheckFunc
- type CheckResult
- func CheckQueryAbsent(db *sql.DB, check Check) (*CheckResult, error)
- func CheckQueryBool(db *sql.DB, check Check, waitFor bool) (*CheckResult, error)
- func CheckQueryPresent(db *sql.DB, check Check) (*CheckResult, error)
- func DiffResults(first, second []CheckResult) []CheckResult
- func FailedCheck(c *Check, message string) *CheckResult
- func ReadReport(f io.Reader) ([]CheckResult, error)
- func ReadReportFile(filePath string) ([]CheckResult, error)
- func RunChecks(dbType, dbConnString string, checks []*Check, concurrency int) ([]CheckResult, error)
- type Row
Constants ¶
This section is empty.
Variables ¶
Error is our error log
Functions ¶
func DiffPretty ¶
DiffPretty returns string with pretty diff between two strings
func FindCheckInCheckResults ¶
func FindCheckInCheckResults(needle Check, list []CheckResult) int
FindCheckInCheckResults returns position of CheckResult with given Check in []CheckResult
func ReportProblems ¶
func ReportProblems(results []CheckResult) (int, string)
ReportProblems counts and pretty print problems
func ResultInSlice ¶
func ResultInSlice(needle CheckResult, list []CheckResult) bool
ResultInSlice checks if we have CheckResult in slice of CheckResults
func ToTabString ¶
ToTabString returns keys and values in CSV format
func WriteReport ¶
func WriteReport(results []CheckResult, f io.Writer) error
WriteReport writes report in CSV format to some io.Writer.
func WriteReportFile ¶
func WriteReportFile(results []CheckResult, filePath string) error
WriteReportFile writes report to file at filePath.
Types ¶
type Check ¶
type Check struct { Description string `yaml:"description"` Query string `yaml:"query"` Assert string `yaml:"assert"` }
Check is a description of check
func ReadCheckFile ¶
ReadCheckFile reads check from file at filePath.
type CheckFunc ¶ added in v0.3.0
type CheckFunc func(*sql.DB, Check) (*CheckResult, error)
CheckFunc is a function we use for checks
type CheckResult ¶
type CheckResult struct { Check Check `json:"check"` Problems []Row `json:"problems"` Columns Row `json:"columns"` }
CheckResult is a result of performed checks
func CheckQueryAbsent ¶
func CheckQueryAbsent(db *sql.DB, check Check) (*CheckResult, error)
CheckQueryAbsent is a checker function that considers any output row a problem
func CheckQueryBool ¶ added in v0.3.0
CheckQueryBool is a checker function that checks boolean output
func CheckQueryPresent ¶
func CheckQueryPresent(db *sql.DB, check Check) (*CheckResult, error)
CheckQueryPresent is a checker function that considers missing output a problem
func DiffResults ¶
func DiffResults(first, second []CheckResult) []CheckResult
DiffResults returns diff (in form of slice of CheckResult) between two slices of CheckResult
func FailedCheck ¶
func FailedCheck(c *Check, message string) *CheckResult
FailedCheck provides easy way to create failed CheckResult
func ReadReport ¶
func ReadReport(f io.Reader) ([]CheckResult, error)
ReadReport reads previous report in CSV format from some io.Reader.
func ReadReportFile ¶
func ReadReportFile(filePath string) ([]CheckResult, error)
ReadReportFile reads report from file at filePath.
func RunChecks ¶
func RunChecks(dbType, dbConnString string, checks []*Check, concurrency int) ([]CheckResult, error)
RunChecks runs all check, uses dbConnString for db connection
func (CheckResult) HasProblems ¶
func (c CheckResult) HasProblems() bool
HasProblems indicates that CheckResult has problems
func (CheckResult) String ¶
func (c CheckResult) String() string
String represents CheckResult as string