-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
50 lines (42 loc) · 1.13 KB
/
main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"flag"
"log"
"os"
"github.com/dparrish/openinstrument"
oproto "github.com/dparrish/openinstrument/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
var (
endKey = flag.String("end_key", "", "End key")
ID = flag.String("id", "", "Block ID")
connectAddress = flag.String("connect", "localhost:8021", "Connect directly to the specified datastore server.")
)
func main() {
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
flag.Parse()
conn, err := grpc.Dial(*connectAddress, grpc.WithInsecure())
if err != nil {
log.Fatalf("Error connecting to %s: %s", *connectAddress, err)
}
defer conn.Close()
request := &oproto.JoinBlockRequest{
Block: &oproto.Block{},
}
if *endKey != "" {
request.Block.EndKey = *endKey
} else if *ID != "" {
request.Block.Id = *ID
} else if len(os.Args) > 1 {
request.Block.Id = os.Args[1]
} else {
log.Fatal("Specify either --end_key or --id")
}
stub := oproto.NewStoreClient(conn)
response, err := stub.JoinBlock(context.Background(), request)
if err != nil {
log.Fatal(err)
}
log.Println(openinstrument.ProtoText(response))
}