mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +08:00
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package reader
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/msgstream"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
|
|
)
|
|
|
|
type statsService struct {
|
|
ctx context.Context
|
|
msgStream *msgstream.PulsarMsgStream
|
|
container *container
|
|
}
|
|
|
|
func newStatsService(ctx context.Context, container *container, pulsarAddress string) *statsService {
|
|
// TODO: add pulsar message stream init
|
|
|
|
return &statsService{
|
|
ctx: ctx,
|
|
container: container,
|
|
}
|
|
}
|
|
|
|
func (sService *statsService) start() {
|
|
sleepMillisecondTime := 1000
|
|
fmt.Println("do segments statistic in ", strconv.Itoa(sleepMillisecondTime), "ms")
|
|
for {
|
|
select {
|
|
case <-sService.ctx.Done():
|
|
return
|
|
default:
|
|
time.Sleep(time.Duration(sleepMillisecondTime) * time.Millisecond)
|
|
sService.sendSegmentStatistic()
|
|
}
|
|
}
|
|
}
|
|
|
|
func (sService *statsService) sendSegmentStatistic() {
|
|
var statisticData = (*sService.container).getSegmentStatistics()
|
|
|
|
// fmt.Println("Publish segment statistic")
|
|
// fmt.Println(statisticData)
|
|
sService.publicStatistic(statisticData)
|
|
}
|
|
|
|
func (sService *statsService) publicStatistic(statistic *internalpb.QueryNodeSegStats) {
|
|
// TODO: publish statistic
|
|
}
|