Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cartservice] GetCart should be async? #372

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/cartservice/src/services/CartService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ public async override Task<Empty> AddItem(AddItemRequest request, ServerCallCont
return Empty;
}

public override Task<Cart> GetCart(GetCartRequest request, ServerCallContext context)
public async override Task<Cart> GetCart(GetCartRequest request, ServerCallContext context)
{
var activity = Activity.Current;
activity?.SetTag("app.user.id", request.UserId);
activity?.AddEvent(new("Fetch cart"));

var cart = _cartStore.GetCartAsync(request.UserId);
var cart = await _cartStore.GetCartAsync(request.UserId);
var totalCart = 0;
foreach (CartItem item in cart.Result.Items) {
foreach (var item in cart.Items)
{
totalCart += item.Quantity;
}
activity?.SetTag("app.cart.items.count", totalCart);
Expand Down