Documentation ¶
Index ¶
- Variables
- type DBConn
- func (dbc *DBConn) Close()
- func (dbc *DBConn) Current() string
- func (dbc *DBConn) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (dbc *DBConn) ExecOnce(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
- func (dbc *DBConn) ID() int64
- func (dbc *DBConn) IsClosed() bool
- func (dbc *DBConn) Kill(reason string) error
- func (dbc *DBConn) Recycle()
- func (dbc *DBConn) Stream(ctx context.Context, query string, callback func(*sqltypes.Result) error, ...) error
- func (dbc *DBConn) VerifyMode() error
- type Pool
- func (cp *Pool) Available() int64
- func (cp *Pool) Capacity() int64
- func (cp *Pool) Close()
- func (cp *Pool) Get(ctx context.Context) (*DBConn, error)
- func (cp *Pool) IdleTimeout() time.Duration
- func (cp *Pool) MaxCap() int64
- func (cp *Pool) Open(appParams, dbaParams *sqldb.ConnParams)
- func (cp *Pool) Put(conn *DBConn)
- func (cp *Pool) SetCapacity(capacity int) (err error)
- func (cp *Pool) SetIdleTimeout(idleTimeout time.Duration)
- func (cp *Pool) StatsJSON() string
- func (cp *Pool) WaitCount() int64
- func (cp *Pool) WaitTime() time.Duration
Constants ¶
This section is empty.
Variables ¶
var ErrConnPoolClosed = vterrors.New(vtrpcpb.Code_INTERNAL, "internal error: unexpected: conn pool is closed")
ErrConnPoolClosed is returned when the connection pool is closed.
Functions ¶
This section is empty.
Types ¶
type DBConn ¶
type DBConn struct {
// contains filtered or unexported fields
}
DBConn is a db connection for tabletserver. It performs automatic reconnects as needed. Its Execute function has a timeout that can kill its own queries and the underlying connection. It will also trigger a CheckMySQL whenever applicable.
func NewDBConn ¶
func NewDBConn( cp *Pool, appParams, dbaParams *sqldb.ConnParams) (*DBConn, error)
NewDBConn creates a new DBConn. It triggers a CheckMySQL if creation fails.
func (*DBConn) Exec ¶
func (dbc *DBConn) Exec(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
Exec executes the specified query. If there is a connection error, it will reconnect and retry. A failed reconnect will trigger a CheckMySQL.
func (*DBConn) ExecOnce ¶
func (dbc *DBConn) ExecOnce(ctx context.Context, query string, maxrows int, wantfields bool) (*sqltypes.Result, error)
ExecOnce executes the specified query, but does not retry on connection errors.
func (*DBConn) Kill ¶
Kill kills the currently executing query both on MySQL side and on the connection side. If no query is executing, it's a no-op. Kill will also not kill a query more than once.
func (*DBConn) Stream ¶
func (dbc *DBConn) Stream(ctx context.Context, query string, callback func(*sqltypes.Result) error, streamBufferSize int, includedFields querypb.ExecuteOptions_IncludedFields) error
Stream executes the query and streams the results.
func (*DBConn) VerifyMode ¶
VerifyMode returns an error if the connection mode is incorrect.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool implements a custom connection pool for tabletserver. It's similar to dbconnpool.ConnPool, but the connections it creates come with built-in ability to kill in-flight queries. These connections also trigger a CheckMySQL call if we fail to connect to MySQL. Other than the connection type, ConnPool maintains an additional pool of dba connections that are used to kill connections.
func (*Pool) Close ¶
func (cp *Pool) Close()
Close will close the pool and wait for connections to be returned before exiting.
func (*Pool) IdleTimeout ¶
IdleTimeout returns the idle timeout for the pool.
func (*Pool) Open ¶
func (cp *Pool) Open(appParams, dbaParams *sqldb.ConnParams)
Open must be called before starting to use the pool.
func (*Pool) SetCapacity ¶
SetCapacity alters the size of the pool at runtime.
func (*Pool) SetIdleTimeout ¶
SetIdleTimeout sets the idleTimeout on the pool.