Beispiel #1
0
// Helper method for conn pools to convert errors
func getOrPanic(pool *dbconnpool.ConnectionPool) dbconnpool.PoolConnection {
	conn, err := pool.Get(0)
	if err == nil {
		return conn
	}
	if err == dbconnpool.CONN_POOL_CLOSED_ERR {
		panic(connPoolClosedErr)
	}
	panic(NewTabletErrorSql(FATAL, err))
}
Beispiel #2
0
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))
}