Skip to content

Commit

Permalink
Merge pull request #21 from ScoreTrak/chore-update-grpc-library
Browse files Browse the repository at this point in the history
update grpc lib import
  • Loading branch information
L1ghtman2k authored Jan 22, 2022
2 parents 5ba5426 + 61d02cf commit 809f112
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
8 changes: 4 additions & 4 deletions payer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions scoretrak.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 809f112

Please sign in to comment.