-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
35 lines (30 loc) · 893 Bytes
/
client.go
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
package main
import (
"context"
"crypto/tls"
"fmt"
v1 "github.com/shortedapp/shorted/shortedapis/pkg/shorted/service/watcher/v1"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
func main() {
creds := credentials.NewTLS(&tls.Config{
// InsecureSkipVerify: false,
})
opts := []grpc.DialOption{
grpc.WithTransportCredentials(creds),
// grpc.WithInsecure(),
}
conn, err := grpc.Dial("watcher-ak2zgjnhlq-ts.a.run.app:443", opts...)
if err != nil {
fmt.Printf("error dailing: %v", err)
}
defer conn.Close()
fmt.Printf("connection state: %v\n", conn.GetState().String())
client := v1.NewWatchServiceClient(conn)
watch, err := client.SyncWatcher(context.Background(), &v1.SyncWatcherRequest{Id: "28f6edfc-7361-4b37-9e36-65814667e9b4"})
if err != nil {
panic(fmt.Errorf("error fetching watch from client: %v", err))
}
fmt.Printf("watch: %v", watch)
}