query

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const QueriesStruct = "Queries"

Variables

This section is empty.

Functions

func NewClickHouseRepo

func NewClickHouseRepo(config query.Config, conn *clickhouse.Conn) query.MonitorRepo

NewClickHouseRepo returns a new query.MonitorRepo

func NewConfig

func NewConfig(startTime, endTime time.Time, limit, offset int) query.Config

NewConfig returns a new query.Config

func NewConfigWithDefault

func NewConfigWithDefault() query.Config

NewConfigWithDefault returns a new query.Config with default value

func NewDASRepo

func NewDASRepo(db middleware.Pool) query.DASRepo

NewDASRepo returns query.DASRepo

func NewDASRepoWithGlobal

func NewDASRepoWithGlobal() query.DASRepo

NewDASRepoWithGlobal returns query.DASRepo with global mysql pool

func NewEmptyQuery

func NewEmptyQuery() query.Query

NewEmptyQuery return query.Query

func NewMySQLRepo

func NewMySQLRepo(config query.Config, conn *mysql.Conn) query.MonitorRepo

NewMySQLRepo returns a new query.MonitorRepo

func NewService

func NewService(config query.Config, dasRepo query.DASRepo) query.Service

NewService returns a new query.Service

func NewServiceWithDefault

func NewServiceWithDefault(config query.Config) query.Service

NewServiceWithDefault returns a new query.Service with default repository

Types

type ClickhouseRepo

type ClickhouseRepo struct {
	// contains filtered or unexported fields
}

func (*ClickhouseRepo) Close

func (cr *ClickhouseRepo) Close() error

Close closes the connection

func (*ClickhouseRepo) GetByDBName

func (cr *ClickhouseRepo) GetByDBName(serviceName, dbName string) ([]query.Query, error)

GetByDBName returns query.Query list by dbNameS

func (*ClickhouseRepo) GetBySQLID

func (cr *ClickhouseRepo) GetBySQLID(serviceName, sqlID string) (query.Query, error)

GetBySQLID returns query.Query by SQL ID

func (*ClickhouseRepo) GetByServiceNames

func (cr *ClickhouseRepo) GetByServiceNames(serviceNames []string) ([]query.Query, error)

GetByServiceNames returns query.Query list by serviceNames

type Config

type Config struct {
	// contains filtered or unexported fields
}

func (*Config) GetEndTime

func (c *Config) GetEndTime() time.Time

GetEndTime returns the end time

func (*Config) GetLimit

func (c *Config) GetLimit() int

GetLimit returns the limit

func (*Config) GetOffset

func (c *Config) GetOffset() int

GetOffset returns the offset

func (*Config) GetStartTime

func (c *Config) GetStartTime() time.Time

GetStartTime returns the start time

func (*Config) IsValid

func (c *Config) IsValid() bool

IsValid checks if the config is valid

func (*Config) SetEndTime

func (c *Config) SetEndTime(endTime time.Time)

SetEndTime sets the end time

func (*Config) SetLimit

func (c *Config) SetLimit(limit int)

SetLimit sets the limit

func (*Config) SetOffset

func (c *Config) SetOffset(offset int)

SetOffset sets the offset

func (*Config) SetStartTime

func (c *Config) SetStartTime(startTime time.Time)

SetStartTime sets the start time

type DASRepo

type DASRepo struct {
	Database middleware.Pool
}

func (*DASRepo) Execute

func (dr *DASRepo) Execute(command string, args ...interface{}) (middleware.Result, error)

Execute executes given command and placeholders on the middleware

func (*DASRepo) Save

func (dr *DASRepo) Save(mysqlClusterID, mysqlServerID, dbID int, sqlID string, startTime, endTime time.Time, limit, offset int) error

Save saves sql information into the middleware

func (*DASRepo) Transaction

func (dr *DASRepo) Transaction() (middleware.Transaction, error)

Transaction returns a middleware.Transaction that could execute multiple commands as a transaction

type MySQLRepo

type MySQLRepo struct {
	// contains filtered or unexported fields
}

func (*MySQLRepo) Close

func (mr *MySQLRepo) Close() error

Close closes the connection

func (*MySQLRepo) GetByDBName

func (mr *MySQLRepo) GetByDBName(serviceName, dbName string) ([]query.Query, error)

GetByDBName returns query.query list by dbName

func (*MySQLRepo) GetBySQLID

func (mr *MySQLRepo) GetBySQLID(serviceName, sqlID string) (query.Query, error)

GetBySQLID return query.query by SQL ID

func (*MySQLRepo) GetByServiceNames

func (mr *MySQLRepo) GetByServiceNames(serviceName []string) ([]query.Query, error)

GetByServiceNames return query.query list by serviceName

type Querier

type Querier struct {
	// contains filtered or unexported fields
}

Querier include config of query and connection pool of DAS repo

func NewQuerier

func NewQuerier(config query.Config, dasRepo query.DASRepo) *Querier

NewQuerier return *Querier

func NewQuerierWithGlobal

func NewQuerierWithGlobal(config query.Config) *Querier

NewQuerierWithGlobal return *Querier with global DASRepo

func (*Querier) GetByDBID

func (q *Querier) GetByDBID(dbID int) ([]query.Query, error)

GetByDBID get queries by db id

func (*Querier) GetByMySQLClusterID

func (q *Querier) GetByMySQLClusterID(mysqlClusterID int) ([]query.Query, error)

GetByMySQLClusterID get queries by mysql cluster id

func (*Querier) GetByMySQLServerID

func (q *Querier) GetByMySQLServerID(mysqlServerID int) ([]query.Query, error)

GetByMySQLServerID get queries by mysql server id

func (*Querier) GetBySQLID

func (q *Querier) GetBySQLID(mysqlServerID int, sqlID string) ([]query.Query, error)

GetBySQLID get queries by sql id

type Query

type Query struct {
	SQLID           string  `middleware:"sql_id" json:"sql_id"`
	Fingerprint     string  `middleware:"fingerprint" json:"fingerprint"`
	Example         string  `middleware:"example" json:"example"`
	DBName          string  `middleware:"db_name" json:"db_name"`
	ExecCount       int     `middleware:"exec_count" json:"exec_count"`
	TotalExecTime   float64 `middleware:"total_exec_time" json:"total_exec_time"`
	AvgExecTime     float64 `middleware:"avg_exec_time" json:"avg_exec_time"`
	RowsExaminedMax int     `middleware:"rows_examined_max" json:"rows_examined_max"`
}

Query include several members of a query

func (*Query) GetAvgExecTime

func (q *Query) GetAvgExecTime() float64

GetAvgExecTime returns the average execution time

func (*Query) GetDBName

func (q *Query) GetDBName() string

GetDBName returns the db name

func (*Query) GetExample

func (q *Query) GetExample() string

GetExample returns the example

func (*Query) GetExecCount

func (q *Query) GetExecCount() int

GetExecCount returns the execution count

func (*Query) GetFingerprint

func (q *Query) GetFingerprint() string

GetFingerprint returns the fingerprint

func (*Query) GetRowsExaminedMax

func (q *Query) GetRowsExaminedMax() int

GetRowsExaminedMax returns the maximum row examined

func (*Query) GetSQLID

func (q *Query) GetSQLID() string

GetSQLID returns the sql identity

func (*Query) GetTotalExecTime

func (q *Query) GetTotalExecTime() float64

GetTotalExecTime returns the total execution time

func (*Query) SetDBName

func (q *Query) SetDBName(dbName string)

SetDBName sets db name to the query

type Service

type Service struct {
	Queries []query.Query `json:"queries"`
	// contains filtered or unexported fields
}

func (*Service) GetByDBID

func (s *Service) GetByDBID(dbID int) error

GetByDBID gets the query slice by the db identity

func (*Service) GetByHostInfo added in v1.1.1

func (s *Service) GetByHostInfo(hostIP string, portNum int) error

GetByHostInfo gets the query slice by the mysql server host ip and port number

func (*Service) GetByMySQLClusterID

func (s *Service) GetByMySQLClusterID(mysqlClusterID int) error

GetByMySQLClusterID gets the query slice by the mysql cluster identity

func (*Service) GetByMySQLServerID

func (s *Service) GetByMySQLServerID(mysqlServerID int) error

GetByMySQLServerID gets the query slice by the mysql server identity

func (*Service) GetBySQLID

func (s *Service) GetBySQLID(mysqlServerID int, sqlID string) error

GetBySQLID gets the query by the mysql server identity and the sql identity

func (*Service) GetConfig

func (s *Service) GetConfig() query.Config

GetConfig returns the config of query

func (*Service) GetQueries

func (s *Service) GetQueries() []query.Query

GetQueries returns the query slice

func (*Service) Marshal

func (s *Service) Marshal() ([]byte, error)

Marshal marshals Service.Queries to json bytes

func (*Service) Save

func (s *Service) Save(mysqlClusterID, mysqlServerID, dbID int, sqlID string) error

Save the query info into DAS repo

Jump to

Keyboard shortcuts

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