advisor

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package advisor defines the interface for analyzing sql statements. The advisor could be syntax checker, index suggestion etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(dbType db.Type, advType Type, f Advisor)

Register makes a advisor available by the provided id. If Register is called twice with the same name or if advisor is nil, it panics.

Types

type Advice

type Advice struct {
	Status  Status
	Code    common.Code
	Title   string
	Content string
}

Advice is the result of an advisor.

func Check

func Check(dbType db.Type, advType Type, ctx Context, statement string) ([]Advice, error)

Check runs the advisor and returns the advices.

type Advisor

type Advisor interface {
	Check(ctx Context, statement string) ([]Advice, error)
}

Advisor is the interface for advisor.

type Context

type Context struct {
	Logger    *zap.Logger
	Charset   string
	Collation string
}

Context is the context for advisor.

type Status

type Status string

Status is the advisor result status.

const (
	// Success is the advisor status for successes.
	Success Status = "SUCCESS"
	// Warn is the advisor status for warnings.
	Warn Status = "WARN"
	// Error is the advisor status for errors.
	Error Status = "ERROR"
)

func (Status) String

func (e Status) String() string

type Type

type Type string

Type is the type of advisor.

const (
	// Fake is a fake advisor type for testing.
	Fake Type = "bb.plugin.advisor.fake"
	// MySQLSyntax is an advisor type for MySQL syntax.
	MySQLSyntax Type = "bb.plugin.advisor.mysql.syntax"
	// MySQLMigrationCompatibility is an advisor type for MySQL migration compatibility.
	MySQLMigrationCompatibility Type = "bb.plugin.advisor.mysql.migration-compatibility"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL