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

(instrument)(carts) create a degraded version of cart service #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
8 changes: 7 additions & 1 deletion src/cartservice/src/services/CartService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ public CartService(ICartStore cartStore)

public async override Task<Empty> AddItem(AddItemRequest request, ServerCallContext context)
{
// delay processing of add-to-cart requests for 1s
System.Threading.Thread.Sleep(1000);
await _cartStore.AddItemAsync(request.UserId, request.Item.ProductId, request.Item.Quantity);
return Empty;
}

public override Task<Cart> GetCart(GetCartRequest request, ServerCallContext context)
{
// delay processing of view cart requests for 1s
System.Threading.Thread.Sleep(1000);
return _cartStore.GetCartAsync(request.UserId);
}

public async override Task<Empty> EmptyCart(EmptyCartRequest request, ServerCallContext context)
{
// delay processing of empty-cart requests for 1s
System.Threading.Thread.Sleep(1000);
await _cartStore.EmptyCartAsync(request.UserId);
return Empty;
}
}
}
}