some inventory
This commit is contained in:
1 parent
9f0d7dc7d8
commit
4dc1d7bc1c
3 files changed
+64
-20
No files matched your search
@@ -44,7 +44,10 @@ func totalReservedKey(sku SKU, locationID LocationID) string {
|
||||
return fmt.Sprintf("total_reserved:%s:%s", sku, locationID)
|
||||
}
|
||||
|
||||
func (s *RedisCartReservationService) ReserveForCart(ctx context.Context, req CartReserveRequest) error {
|
||||
// Reserve satisfies inventory.ReservationPolicy (platform/inventory).
|
||||
// Method renamed from ReserveForCart as part of cut-30.x: land the ReservationPolicy
|
||||
// interface seam — see docs/inventory-shape.md §Shallow — `ReservationPolicy` interface.
|
||||
func (s *RedisCartReservationService) Reserve(ctx context.Context, req CartReserveRequest) error {
|
||||
keys := []string{
|
||||
getInventoryKey(req.SKU, req.LocationID),
|
||||
cartQtyKey(req.SKU, req.LocationID),
|
||||
@@ -69,7 +72,10 @@ func (s *RedisCartReservationService) ReserveForCart(ctx context.Context, req Ca
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *RedisCartReservationService) ReleaseForCart(ctx context.Context, sku SKU, locationID LocationID, cartID CartID) error {
|
||||
// Release satisfies inventory.ReservationPolicy (platform/inventory).
|
||||
// Method renamed from ReleaseForCart as part of cut-30.x: land the ReservationPolicy
|
||||
// interface seam — see docs/inventory-shape.md §Shallow — `ReservationPolicy` interface.
|
||||
func (s *RedisCartReservationService) Release(ctx context.Context, sku SKU, locationID LocationID, cartID CartID) error {
|
||||
keys := []string{
|
||||
cartQtyKey(sku, locationID),
|
||||
cartExpKey(sku, locationID),
|
||||
@@ -133,7 +139,7 @@ func (s *RedisCartReservationService) GetReservationSummary(ctx context.Context,
|
||||
}
|
||||
|
||||
// Get remaining items
|
||||
remainingItems, err := s.GetAvailableInventory(ctx, sku, locationID)
|
||||
remainingItems, err := s.Available(ctx, sku, locationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -145,7 +151,10 @@ func (s *RedisCartReservationService) GetReservationSummary(ctx context.Context,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *RedisCartReservationService) GetAvailableInventory(ctx context.Context, sku SKU, locationID LocationID) (int64, error) {
|
||||
// Available satisfies inventory.ReservationPolicy (platform/inventory).
|
||||
// Method renamed from GetAvailableInventory as part of cut-30.x: land the
|
||||
// ReservationPolicy interface seam — see docs/inventory-shape.md.
|
||||
func (s *RedisCartReservationService) Available(ctx context.Context, sku SKU, locationID LocationID) (int64, error) {
|
||||
keys := []string{
|
||||
getInventoryKey(sku, locationID),
|
||||
cartQtyKey(sku, locationID),
|
||||
|
||||
Reference in new issue
Block a user