Beispiel #1
0
func NewActiveTxPool(timeout time.Duration) *ActiveTxPool {
	return &ActiveTxPool{
		pool:    pools.NewNumbered(),
		lastId:  time.Now().UnixNano(),
		timeout: int64(timeout),
		ticks:   timer.NewTimer(timeout / 10),
		txStats: stats.NewTimings("Transactions"),
	}
}
Beispiel #2
0
func NewSqlQuery(poolSize, transactionCap int, transactionTimeout float64, maxResultSize, queryCacheSize int, schemaReloadTime, queryTimeout, idleTimeout float64) *SqlQuery {
	self := &SqlQuery{}
	self.schemaInfo = NewSchemaInfo(queryCacheSize, time.Duration(schemaReloadTime*1e9))
	self.connPool = NewConnectionPool(poolSize, time.Duration(idleTimeout*1e9))
	self.reservedPool = NewReservedPool()
	self.txPool = NewConnectionPool(transactionCap, time.Duration(idleTimeout*1e9)) // connections in pool has to be > transactionCap
	self.activeTxPool = NewActiveTxPool(time.Duration(transactionTimeout * 1e9))
	self.activePool = NewActivePool(time.Duration(queryTimeout*1e9), time.Duration(idleTimeout*1e9))
	self.consolidator = NewConsolidator()
	self.maxResultSize = int32(maxResultSize)
	expvar.Publish("Voltron", stats.StrFunc(func() string { return self.statsJSON() }))
	queryStats = stats.NewTimings("Queries")
	stats.NewRates("QPS", queryStats, 15, 60e9)
	waitStats = stats.NewTimings("Waits")
	killStats = stats.NewCounters("Kills")
	errorStats = stats.NewCounters("Errors")
	resultStats = stats.NewHistogram("Results", resultBuckets)
	return self
}
Beispiel #3
0
func init() {
	mysqlStats = stats.NewTimings("MySQL")
}