本文整理汇总了Golang中github.com/youtube/vitess/go/vt/dbconnpool.ConnectionPool类的典型用法代码示例。如果您正苦于以下问题:Golang ConnectionPool类的具体用法?Golang ConnectionPool怎么用?Golang ConnectionPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectionPool类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getOrPanic
// Helper method for conn pools to convert errors
func getOrPanic(pool *dbconnpool.ConnectionPool) dbconnpool.PoolConnection {
conn, err := pool.Get()
if err == nil {
return conn
}
if err == dbconnpool.CONN_POOL_CLOSED_ERR {
panic(connPoolClosedErr)
}
panic(NewTabletErrorSql(FATAL, err))
}
开发者ID:nangong92t,项目名称:go_src,代码行数:11,代码来源:query_engine.go
示例2: getConn
func (rqc *RequestContext) getConn(pool *dbconnpool.ConnectionPool) dbconnpool.PoolConnection {
start := time.Now()
timeout, err := rqc.deadline.Timeout()
if err != nil {
panic(NewTabletError(FAIL, "getConn: %v", err))
}
conn, err := pool.Get(timeout)
switch err {
case nil:
rqc.logStats.WaitingForConnection += time.Now().Sub(start)
return conn
case dbconnpool.CONN_POOL_CLOSED_ERR:
panic(connPoolClosedErr)
}
panic(NewTabletErrorSql(FATAL, err))
}
开发者ID:plobsing,项目名称:vitess,代码行数:16,代码来源:request_context.go
示例3: getPoolReconnect
// getPoolReconnect gets a connection from a pool, tests it, and reconnects if
// it gets errno 2006.
func getPoolReconnect(ctx context.Context, pool *dbconnpool.ConnectionPool) (dbconnpool.PoolConnection, error) {
conn, err := pool.Get(ctx)
if err != nil {
return conn, err
}
// Run a test query to see if this connection is still good.
if _, err := conn.ExecuteFetch("SELECT 1", 1, false); err != nil {
// If we get "MySQL server has gone away (errno 2006)", try to reconnect.
if sqlErr, ok := err.(*sqldb.SQLError); ok && sqlErr.Number() == 2006 {
if err := conn.Reconnect(); err != nil {
conn.Recycle()
return conn, err
}
}
}
return conn, nil
}
开发者ID:jmptrader,项目名称:vitess,代码行数:19,代码来源:query.go
注:本文中的github.com/youtube/vitess/go/vt/dbconnpool.ConnectionPool类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论