frontend: more organization
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
ef92ddc351
commit
7063092393
4 changed files with 41 additions and 8 deletions
|
@ -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})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue