本文整理汇总了Golang中github.com/influxdata/influxdb/tsdb.PointBatcher类的典型用法代码示例。如果您正苦于以下问题:Golang PointBatcher类的具体用法?Golang PointBatcher怎么用?Golang PointBatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PointBatcher类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkPointBatcherStats
func checkPointBatcherStats(t *testing.T, b *tsdb.PointBatcher, batchTotal, pointTotal, sizeTotal, timeoutTotal int) {
stats := b.Stats()
if batchTotal != -1 && stats.BatchTotal != uint64(batchTotal) {
t.Errorf("batch total stat is incorrect: %d", stats.BatchTotal)
}
if pointTotal != -1 && stats.PointTotal != uint64(pointTotal) {
t.Errorf("point total stat is incorrect: %d", stats.PointTotal)
}
if sizeTotal != -1 && stats.SizeTotal != uint64(sizeTotal) {
t.Errorf("size total stat is incorrect: %d", stats.SizeTotal)
}
if timeoutTotal != -1 && stats.TimeoutTotal != uint64(timeoutTotal) {
t.Errorf("timeout total stat is incorrect: %d", stats.TimeoutTotal)
}
}
示例2: processBatches
// processBatches continually drains the given batcher and writes the batches to the database.
func (s *Service) processBatches(batcher *tsdb.PointBatcher) {
defer s.wg.Done()
for {
select {
case batch := <-batcher.Out():
if err := s.PointsWriter.WritePoints(s.database, s.retentionPolicy, models.ConsistencyLevelAny, batch); err == nil {
s.statMap.Add(statBatchesTransmitted, 1)
s.statMap.Add(statPointsTransmitted, int64(len(batch)))
} else {
s.logger.Printf("failed to write point batch to database %q: %s", s.database, err)
s.statMap.Add(statBatchesTransmitFail, 1)
}
case <-s.done:
return
}
}
}
示例3: processBatches
// processBatches continually drains the given batcher and writes the batches to the database.
func (s *Service) processBatches(batcher *tsdb.PointBatcher) {
for {
select {
case <-s.done:
return
case batch := <-batcher.Out():
// Will attempt to create database if not yet created.
if err := s.createInternalStorage(); err != nil {
s.Logger.Info(fmt.Sprintf("Required database %s does not yet exist: %s", s.Database, err.Error()))
continue
}
if err := s.PointsWriter.WritePoints(s.Database, s.RetentionPolicy, models.ConsistencyLevelAny, batch); err == nil {
atomic.AddInt64(&s.stats.BatchesTransmitted, 1)
atomic.AddInt64(&s.stats.PointsTransmitted, int64(len(batch)))
} else {
s.Logger.Info(fmt.Sprintf("failed to write point batch to database %q: %s", s.Database, err))
atomic.AddInt64(&s.stats.BatchesTransmitFail, 1)
}
}
}
}