Debian Codegraph @

firestore/examples/end2end/src/apimethods/rollback.go

raw
1 package apimethods
2
3 import (
4 "context"
5 "environment"
6 "fmt"
7 "fsutils"
8 firestore "go-genproto/googleapis/firestore/v1beta1"
9 )
10
11 //Rollback ... Call the Rollback API
12 func Rollback() {
13 fmt.Println("\n:: Calling Rollback API ::\n")
14 client, conn := fsutils.MakeFSClient()
15
16 defer conn.Close()
17
18 env := environment.GetEnvironment()
19
20 if env == nil {
21 fmt.Println("\nNo transaction to rollback, returning...")
22 return
23 }
24
25 transactionId := env.TransactionId
26
27 rollbackReq := firestore.RollbackRequest{
28 Database: "projects/firestoretestclient/databases/(default)",
29 Transaction: transactionId,
30 }
31 resp, err := client.Rollback(context.Background(), &rollbackReq)
32
33 if err != nil {
34 fmt.Println(err)
35 return
36 }
37 environment.ClearEnvironment()
38 fmt.Println("Successful rollback! ", resp)
39 }