mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
81e70ee6c9
Signed-off-by: xige-16 <xi.ge@zilliz.com>
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/czs007/suvlim/storage/pkg"
|
|
"github.com/czs007/suvlim/storage/pkg/types"
|
|
"github.com/czs007/suvlim/writer/message_client"
|
|
"github.com/czs007/suvlim/writer/write_node"
|
|
"log"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
|
|
mc := message_client.MessageClient{}
|
|
mc.InitClient("pulsar://localhost:6650")
|
|
//mc.InitClient("pulsar://192.168.2.18:6650")
|
|
//TODO::close client / consumer/ producer
|
|
//mc.Close()
|
|
|
|
go mc.ReceiveMessage()
|
|
wg := sync.WaitGroup{}
|
|
ctx := context.Background()
|
|
kv, err := storage.NewStore(ctx, types.MinIODriver)
|
|
// if err != nil, should retry link
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
wn := write_node.WriteNode{
|
|
KvStore: &kv,
|
|
MessageClient: &mc,
|
|
TimeSync: 100,
|
|
}
|
|
|
|
for {
|
|
time.Sleep(200 * time.Millisecond)
|
|
msgLength := wn.MessageClient.PrepareBatchMsg()
|
|
readyDo := false
|
|
for _, len := range msgLength {
|
|
if len > 0 { readyDo = true }
|
|
}
|
|
if readyDo {
|
|
wn.DoWriteNode(ctx, 100, &wg)
|
|
fmt.Println("write node do a batch message, storage len: ")
|
|
}
|
|
fmt.Println("do a batch in 200ms")
|
|
}
|
|
}
|