connect cartservice
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
36b7b9eb65
commit
f3fe6d42ad
8 changed files with 93 additions and 14 deletions
|
@ -3,7 +3,11 @@ package main
|
|||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
pb "frontend/genproto"
|
||||
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -37,6 +41,15 @@ func (fe *frontendServer) getProduct(ctx context.Context, id string) (*pb.Produc
|
|||
return resp, err
|
||||
}
|
||||
|
||||
func (fe *frontendServer) getCart(ctx context.Context, userID string) ([]*pb.CartItem, error) {
|
||||
resp, err := pb.NewCartServiceClient(fe.cartSvcConn).GetCart(ctx, &pb.GetCartRequest{UserId: userID})
|
||||
if status.Code(err) == codes.Canceled {
|
||||
// TODO(ahmetb) remove this workaround when cartservice returns ok response to GetCart() with non-existing users
|
||||
return nil, nil
|
||||
}
|
||||
return resp.GetItems(), err
|
||||
}
|
||||
|
||||
func (fe *frontendServer) convertCurrency(ctx context.Context, money *pb.Money, currency string) (*pb.Money, error) {
|
||||
if avoidNoopCurrencyConversionRPC && money.GetCurrencyCode() == currency {
|
||||
return money, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue