This repository has no description
1//go:build ignore
2
3// Example: how appview will call gitmirror's GitMirrorService.
4//
5// This file is build-ignored so it never breaks `go build ./...`. It is a
6// copy-ready reference for wiring the client into appview once the Go stubs
7// are generated (see gitmirror/buf.gen.yaml).
8package main
9
10import (
11 "context"
12 "log"
13 "time"
14
15 "google.golang.org/grpc"
16 "google.golang.org/grpc/credentials/insecure"
17
18 gitmirrorv1 "tangled.org/core/gitmirror/proto/gen"
19)
20
21func main() {
22 conn, err := grpc.NewClient("127.0.0.1:9000",
23 grpc.WithTransportCredentials(insecure.NewCredentials()))
24 if err != nil {
25 log.Fatal(err)
26 }
27 defer conn.Close()
28
29 client := gitmirrorv1.NewGitMirrorServiceClient(conn)
30 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
31 defer cancel()
32
33 // appview converts its syntax.DID to a string via did.String().
34 resp, err := client.Commits(ctx, &gitmirrorv1.CommitsRequest{
35 Repo: "did:plc:example",
36 Options: &gitmirrorv1.CommitsOptions{},
37 })
38 if err != nil {
39 log.Fatal(err)
40 }
41 log.Println(resp.GetCommits())
42}