forked from cr7258/kubernetes-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrud.go
More file actions
44 lines (36 loc) · 1.08 KB
/
crud.go
File metadata and controls
44 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"context"
"flag"
"fmt"
"log"
"time"
pb "github.com/qdrant/go-client/qdrant"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
var (
addr = flag.String("addr", "localhost:6334", "the address to connect to")
)
func main() {
flag.Parse()
// Set up a connection to the server.
conn, err := grpc.Dial(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
collections_client := pb.NewCollectionsClient(conn)
// Contact the server and print out its response.
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
// List collections
r, err := collections_client.List(ctx, &pb.ListCollectionsRequest{})
if err != nil {
log.Fatalf("could not get collections: %v", err)
}
log.Printf("List of collections: %s", r.GetCollections())
// Get collection
getCollectionInfoResponse, err := collections_client.Get(ctx, &pb.GetCollectionInfoRequest{CollectionName: "kubernet1es"})
fmt.Println(getCollectionInfoResponse)
}