Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
1.1 kB · 42 lines
Go
12345678910111213141516171819202122232425262728293031323334353637383940414243//go:build ignore
// Example: how appview will call gitmirror's GitMirrorService.//// This file is build-ignored so it never breaks `go build ./...`. It is a// copy-ready reference for wiring the client into appview once the Go stubs// are generated (see gitmirror/buf.gen.yaml).package main
import ( "context" "log" "time"
"google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure"
gitmirrorv1 "tangled.org/core/gitmirror/proto/gen")
func main() { conn, err := grpc.NewClient("127.0.0.1:9000", grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Fatal(err) } defer conn.Close()
client := gitmirrorv1.NewGitMirrorServiceClient(conn) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel()
// appview converts its syntax.DID to a string via did.String(). resp, err := client.Commits(ctx, &gitmirrorv1.CommitsRequest{ Repo: "did:plc:example", Options: &gitmirrorv1.CommitsOptions{}, }) if err != nil { log.Fatal(err) } log.Println(resp.GetCommits())}