mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
be58ccb65e
Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
64 lines
1.5 KiB
Go
64 lines
1.5 KiB
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"time"
|
|
|
|
pb "github.com/czs007/suvlim/pkg/master/grpc/master"
|
|
msgpb "github.com/czs007/suvlim/pkg/master/grpc/message"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// func main() {
|
|
// // Set up a connection to the server.
|
|
// conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
|
|
// if err != nil {
|
|
// log.Fatalf("did not connect: %v", err)
|
|
// }
|
|
// defer conn.Close()
|
|
// c := pb.NewGreeterClient(conn)
|
|
|
|
// // Contact the server and print out its response.
|
|
// name := defaultName
|
|
// if len(os.Args) > 1 {
|
|
// name = os.Args[1]
|
|
// }
|
|
// ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
|
// defer cancel()
|
|
// r, err := c.SayHello(ctx, &pb.HelloRequest{Name: name})
|
|
// if err != nil {
|
|
// log.Fatalf("could not greet: %v", err)
|
|
// }
|
|
// log.Printf("Greeting: %s", r.GetMessage())
|
|
// }
|
|
|
|
const (
|
|
addr = "192.168.1.10:53100"
|
|
)
|
|
|
|
func FakeCreateCollectionByGRPC() (string, uint64) {
|
|
conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithBlock())
|
|
if err != nil {
|
|
log.Fatalf("did not connect: %v", err)
|
|
}
|
|
defer conn.Close()
|
|
|
|
c := pb.NewMasterClient(conn)
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
|
|
|
defer cancel()
|
|
|
|
r, err := c.CreateCollection(ctx, &msgpb.Mapping{
|
|
CollectionName: "test-collection",
|
|
})
|
|
if err != nil {
|
|
log.Fatalf("could not greet: %v", err)
|
|
}
|
|
|
|
// log.Printf("CreateCollection: %s, id: %d", r.GetCollectionName(), r.GetCollectionId())
|
|
// return r.GetCollectionName(), r.GetCollectionId()
|
|
return r.GetReason(), 0
|
|
}
|