frontend: more organization

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-06-25 11:17:51 -07:00
parent ef92ddc351
commit 7063092393
4 changed files with 41 additions and 8 deletions

View file

@ -6,6 +6,10 @@ import (
pb "frontend/genproto"
)
const (
avoidNoopCurrencyConversionRPC = false
)
func (fe *frontendServer) getCurrencies(ctx context.Context) ([]string, error) {
currs, err := pb.NewCurrencyServiceClient(fe.currencySvcConn).
GetSupportedCurrencies(ctx, &pb.Empty{})
@ -26,3 +30,13 @@ func (fe *frontendServer) getProducts(ctx context.Context) ([]*pb.Product, error
ListProducts(ctx, &pb.Empty{})
return resp.GetProducts(), err
}
func (fe *frontendServer) convertCurrency(ctx context.Context, money *pb.Money, currency string) (*pb.Money, error) {
if avoidNoopCurrencyConversionRPC && money.GetCurrencyCode() == currency {
return money, nil
}
return pb.NewCurrencyServiceClient(fe.currencySvcConn).
Convert(ctx, &pb.CurrencyConversionRequest{
From: money,
ToCode: currency})
}