Documentation ¶
Index ¶
- Variables
- func GetCurrentGTID(addr *Addr) (string, error)
- func GetCurrentGTIDForDB(loc *Loc, inputType string) (string, error)
- func GetPurgedGTID(addr *Addr) (string, error)
- func IsValidConnByType(dbl *Loc, connType ConnectionType, addr *Addr, inputType string) bool
- func IsValidConnForTest(_ *Loc, _ ConnectionType, _ *Addr, _ string) bool
- func JSONServer(js string) (*httptest.Server, map[string]json.RawMessage)
- func Open(ci *Addr) (*sql.DB, error)
- func OpenModeType(ci *Addr, drv, mode string) (*sql.DB, error)
- func OpenService(dbl *Loc, substDB string, inputType string) (*sql.DB, error)
- type Addr
- type BuiltinEnumerator
- type BuiltinResolver
- func (r *BuiltinResolver) GetEnumerator(ctx context.Context, svc, cluster, sdb, table string) (Enumerator, error)
- func (r *BuiltinResolver) GetInfo(ctx context.Context, dbl *Loc, connType ConnectionType) (*Addr, error)
- func (r *BuiltinResolver) IsValidConn(ctx context.Context, dbl *Loc, connType ConnectionType, addr *Addr) bool
- type ConnectionType
- type Enumerator
- type Loc
- type Resolver
- type TableLoc
Constants ¶
This section is empty.
Variables ¶
var BuiltinResolveCluster func(*Loc, ConnectionType) (*Addr, error)
BuiltinResolveCluster to implement runtime polymorphism and resolve cyclic package dependency. state.SchemaGet will be assigned to in main.go and connectInfoGetFortest in db/open_test.go
var GetConnInfo = GetConnInfoByType
GetConnInfo is database address resolving function
var GetEnumerator = GetEnumeratorByType
GetEnumerator is database location enumerating function
var IsValidConn = IsValidConnByType
IsValidConn is database connection validator function that verifies connection is to the correct DB
var SQLMode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
SQLMode can be substituted by tests Difference from default value is ONLY_FULL_GROUP_BY removed, required by state SQL joins
Functions ¶
func GetCurrentGTID ¶
GetCurrentGTID returns current gtid set for the specified db address (host,port,user,password)
func GetCurrentGTIDForDB ¶
GetCurrentGTIDForDB return current gtid set for the db specified by db locator (cluster,service,db)
func GetPurgedGTID ¶
GetPurgedGTID returns purged gtid set for the specified db address (host,port,user,password)
func IsValidConnByType ¶
func IsValidConnByType(dbl *Loc, connType ConnectionType, addr *Addr, inputType string) bool
IsValidConnByType checks the validity of the connection to make sure connection is to the correct DB
func IsValidConnForTest ¶
func IsValidConnForTest(_ *Loc, _ ConnectionType, _ *Addr, _ string) bool
IsValidConnForTest is DB connection validator for tests
func JSONServer ¶
JSONServer starts a new server which serves json that's passed to it as an argument. The string should be json with a map of url->response. If the response is "error" then the server will return 500.
func OpenModeType ¶
OpenModeType opens database connection by given address
Types ¶
type Addr ¶
type Addr struct { Name string `json:"name"` Host string `json:"host"` Port uint16 `json:"port"` User string `json:"user"` Pwd string `json:"pwd"` DB string `json:"db"` }
Addr contains information required to connect to DB
func GetConnInfoByType ¶
func GetConnInfoByType(dbl *Loc, connType ConnectionType, inputType string) (*Addr, error)
GetConnInfoByType returns DB connection info by type of DB node
func GetConnInfoForTest ¶
func GetConnInfoForTest(dbl *Loc, connType ConnectionType, inputType string) (*Addr, error)
GetConnInfoForTest return address of local MySQL used by tests
type BuiltinEnumerator ¶
type BuiltinEnumerator struct {
// contains filtered or unexported fields
}
BuiltinEnumerator implements a db location enumerator for MySQL
func (*BuiltinEnumerator) Next ¶
func (e *BuiltinEnumerator) Next() bool
Next is used to check if anymore values can be returned by the enumerator
func (*BuiltinEnumerator) Reset ¶
func (e *BuiltinEnumerator) Reset()
Reset resets the enumerator to the starting point
func (*BuiltinEnumerator) Value ¶
func (e *BuiltinEnumerator) Value() *Loc
Value returns the current value from the enumerator
type BuiltinResolver ¶
type BuiltinResolver struct { }
BuiltinResolver resolves MySQL connection info for SOA databases using Nemo
func (*BuiltinResolver) GetEnumerator ¶
func (r *BuiltinResolver) GetEnumerator(ctx context.Context, svc, cluster, sdb, table string) (Enumerator, error)
GetEnumerator returns an enumerator for db location info fetched from Nemo
func (*BuiltinResolver) GetInfo ¶
func (r *BuiltinResolver) GetInfo(ctx context.Context, dbl *Loc, connType ConnectionType) (*Addr, error)
GetInfo returns MySQL connection info
func (*BuiltinResolver) IsValidConn ¶
func (r *BuiltinResolver) IsValidConn(ctx context.Context, dbl *Loc, connType ConnectionType, addr *Addr) bool
IsValidConn checks the validity of the connection to make sure connection is to the correct MySQL DB
type ConnectionType ¶
type ConnectionType int
ConnectionType is used as enum to represent connection types
const ( // Master is the type corresponding to a master or a leader Master ConnectionType = iota // Slave is the type corresponding to a slave or a follower Slave )
func (ConnectionType) String ¶
func (c ConnectionType) String() string
type Enumerator ¶
Enumerator defines an iterator that allows iterating over db locations
func GetEnumeratorByType ¶
func GetEnumeratorByType(svc, cluster, sdb, table, inputType string) (Enumerator, error)
GetEnumeratorByType returns a DB location enumerator depending on the input type
func GetEnumeratorForTest ¶
func GetEnumeratorForTest(svc, cluster, sdb, table, inputType string) (Enumerator, error)
GetEnumeratorForTest return db location info enumerator used by tests
type Resolver ¶
type Resolver interface { GetInfo(context.Context, *Loc, ConnectionType) (*Addr, error) GetEnumerator(context.Context, string, string, string, string) (Enumerator, error) IsValidConn(ctx context.Context, dbl *Loc, connType ConnectionType, addr *Addr) bool }
Resolver defines a MySQL connection info resolver
func NewBuiltinResolver ¶
func NewBuiltinResolver() Resolver
NewBuiltinResolver returns a new resolver for resolving connection info using Nemo
func NewResolver ¶
NewResolver returns a MySQL connection info resolver depending on the input type