From 61d02cf6f793da4d0a6681e32e17ed87a2ff70ea Mon Sep 17 00:00:00 2001 From: Ibrahim Diallo <20114089+thisisibrahimd@users.noreply.github.com> Date: Fri, 21 Jan 2022 21:34:59 -0500 Subject: [PATCH] update grpc lib import --- go.mod | 1 + go.sum | 3 +++ payer.go | 8 ++++---- scoretrak.go | 12 ++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index e470596..f43d13d 100644 --- a/go.mod +++ b/go.mod @@ -21,6 +21,7 @@ require ( github.com/jlaffaye/ftp v0.0.0-20210307004419-5d4190119067 // indirect github.com/masterzen/winrm v0.0.0-20210623064412-3b76017826b0 // indirect github.com/miekg/dns v1.1.43 // indirect + go.buf.build/grpc/go/scoretrak/scoretrakapis v1.2.3 golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6 // indirect golang.org/x/sys v0.0.0-20211001092434-39dca1131b70 // indirect golang.org/x/term v0.0.0-20210429154555-c04ba851c2a4 // indirect diff --git a/go.sum b/go.sum index 7c26f4c..b751821 100644 --- a/go.sum +++ b/go.sum @@ -377,6 +377,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.buf.build/grpc/go/scoretrak/scoretrakapis v1.2.3 h1:erSo/xT0d26Veod7oOayjHLssCDlLkXvugcDXoY3xzI= +go.buf.build/grpc/go/scoretrak/scoretrakapis v1.2.3/go.mod h1:xyShp52X0wA9xIACsyrt+rZyCOF7rtUj0QbPpTUWV+g= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -565,6 +567,7 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= diff --git a/payer.go b/payer.go index ea16761..7c8fb43 100644 --- a/payer.go +++ b/payer.go @@ -3,11 +3,11 @@ package main import ( "flag" "github.com/ScoreTrak/ScoreTrak/pkg/auth" - authpb "github.com/ScoreTrak/ScoreTrak/pkg/proto/auth/v1" - reportpb "github.com/ScoreTrak/ScoreTrak/pkg/proto/report/v1" "github.com/ScoreTrak/ScoreTrak/pkg/storage" "github.com/ScoreTrak/payments/report" "github.com/golang-jwt/jwt/v4" + authv1 "go.buf.build/grpc/go/scoretrak/scoretrakapis/scoretrak/auth/v1" + reportv1 "go.buf.build/grpc/go/scoretrak/scoretrakapis/scoretrak/report/v1" "google.golang.org/grpc" "log" "net/http" @@ -36,7 +36,7 @@ func main() { if err != nil { log.Fatal("cannot dial server: ", err) } - authClient := authpb.NewAuthServiceClient(cc) + authClient := authv1.NewAuthServiceClient(cc) log.Println("Requesting authentication token") t, err := getAuth(authClient) if err != nil { @@ -52,7 +52,7 @@ func main() { } log.Println("Authentication token is valid until " + claims.ExpiresAt.Time.String()) log.Println("Requesting report") - reportClient := reportpb.NewReportServiceClient(cc) + reportClient := reportv1.NewReportServiceClient(cc) latestReport, err := getReport(reportClient, t) if err != nil { log.Fatalln(err) diff --git a/scoretrak.go b/scoretrak.go index 1b4485d..e8e41df 100644 --- a/scoretrak.go +++ b/scoretrak.go @@ -3,24 +3,24 @@ package main import ( "context" "encoding/json" - authpb "github.com/ScoreTrak/ScoreTrak/pkg/proto/auth/v1" - reportpb "github.com/ScoreTrak/ScoreTrak/pkg/proto/report/v1" "github.com/ScoreTrak/ScoreTrak/pkg/report" + authv1 "go.buf.build/grpc/go/scoretrak/scoretrakapis/scoretrak/auth/v1" + reportv1 "go.buf.build/grpc/go/scoretrak/scoretrakapis/scoretrak/report/v1" "google.golang.org/grpc/metadata" "log" ) -func getAuth(acli authpb.AuthServiceClient) (string, error) { - resp, err := acli.Login(context.Background(), &authpb.LoginRequest{Password: conf.ScoreTrakPassword, Username: conf.ScoreTrakUsername}) +func getAuth(acli authv1.AuthServiceClient) (string, error) { + resp, err := acli.Login(context.Background(), &authv1.LoginRequest{Password: conf.ScoreTrakPassword, Username: conf.ScoreTrakUsername}) if err != nil { return "", err } return resp.AccessToken, nil } -func getReport(repCli reportpb.ReportServiceClient, token string) (*report.SimpleReport, error) { +func getReport(repCli reportv1.ReportServiceClient, token string) (*report.SimpleReport, error) { ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs("authorization", token)) - resp, err := repCli.Get(ctx, &reportpb.GetRequest{}) + resp, err := repCli.Get(ctx, &reportv1.GetRequest{}) if err != nil { return nil, err }