func NewQueryEngine(config Config) *QueryEngine { var err error qe := &QueryEngine{} qe.engine, err = kvengine.NewEngine(config.EngineName) if err != nil { panic(NewTabletErrorDB(FATAL, err)) } qe.connPool = NewConnectionPool("ConnPool", config.PoolSize, time.Duration(config.IdleTimeout*1e9)) qe.schemaInfo = NewSchemaInfo(config.QueryCacheSize, time.Duration(config.IdleTimeout*1e9)) qe.consolidator = NewConsolidator() qe.maxResultSize = sync2.AtomicInt64(config.MaxResultSize) qe.streamBufferSize = sync2.AtomicInt64(config.StreamBufferSize) stats.Publish("MaxResultSize", stats.IntFunc(qe.maxResultSize.Get)) stats.Publish("StreamBufferSize", stats.IntFunc(qe.streamBufferSize.Get)) queryStats = stats.NewTimings("Queries") QPSRates = stats.NewRates("QPS", queryStats, 15, 60*time.Second) waitStats = stats.NewTimings("Waits") errorStats = stats.NewCounters("Errors") resultStats = stats.NewHistogram("Results", resultBuckets) return qe }
package streamlog import ( "io" "net/http" "net/url" "sync" "github.com/senarukana/rationaldb/log" "github.com/senarukana/rationaldb/util/stats" "github.com/senarukana/rationaldb/util/sync2" ) var droppedMessages = stats.NewCounters("StreamlogDroppedMessages") // A StreamLogger makes messages sent to it available through HTTP. type StreamLogger struct { dataQueue chan Formatter subscribed map[io.Writer]subscription name string mu sync.Mutex // size is used to check if there are any subscriptions. Keep // it atomically in sync with the size of subscribed. size sync2.AtomicUint32 // seq is a guard for modifications of subscribed - increment // it atomically whenever you modify it. seq sync2.AtomicUint32 } type subscription struct { done chan bool