fix
This commit is contained in:
@@ -17,9 +17,10 @@
|
||||
// listener.go subscribes to the inventory_changed Redis pub/sub channel
|
||||
// and mirrors upstream events into the local cache.
|
||||
//
|
||||
// TODO: types.go mixes storage types (InventoryItem, InventoryReference)
|
||||
// with request types (CartReserveRequest, ReserveRequest). Split into
|
||||
// `types/storage.go` and `types/cart.go` so callers can depend on only
|
||||
// what they need. Start by moving CartReserveRequest + ReserveRequest to
|
||||
// `types/cart.go` and adjusting the imports in cmd/*.
|
||||
// Request and reservation DTOs (CartReserveRequest, ReserveRequest,
|
||||
// CartID, ReservationStatus, ReservationSummary) now live in
|
||||
// request_types.go. Storage types (InventoryItem, InventoryReference,
|
||||
// InventoryResult) remain in types.go. When adding a new request shape,
|
||||
// put it in request_types.go; when adding a new storage shape, put it
|
||||
// in types.go.
|
||||
package inventory
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package inventory
|
||||
|
||||
import "time"
|
||||
|
||||
// Request and reservation DTOs — separated from storage types (types.go)
|
||||
// so callers that only need read-side shapes don't pull in cart-reservation
|
||||
// concepts. See doc.go for the split rationale.
|
||||
|
||||
type CartID string
|
||||
|
||||
type ReserveRequest struct {
|
||||
*InventoryReference
|
||||
Quantity uint32
|
||||
}
|
||||
|
||||
type CartReserveRequest struct {
|
||||
*InventoryReference
|
||||
CartID CartID
|
||||
Quantity uint32
|
||||
TTL time.Duration
|
||||
}
|
||||
|
||||
// CartReservationService interface was removed in favor of
|
||||
// platform/inventory.ReservationPolicy. Consumers should depend on the
|
||||
// platform seam; the concrete *RedisCartReservationService implements its
|
||||
// methods directly.
|
||||
|
||||
type ReservationStatus struct {
|
||||
Active bool
|
||||
RemainingTime time.Duration
|
||||
}
|
||||
|
||||
type ReservationSummary struct {
|
||||
ReservationCount int64 `json:"reservation_count"`
|
||||
EarliestRelease time.Time `json:"earliest_release"`
|
||||
RemainingItems int64 `json:"remaining_items"`
|
||||
}
|
||||
@@ -33,37 +33,7 @@ type InventoryService interface {
|
||||
ReservationCheck(ctx context.Context, req ...ReserveRequest) (*ReserveRequest, error)
|
||||
}
|
||||
|
||||
type ReserveRequest struct {
|
||||
*InventoryReference
|
||||
Quantity uint32
|
||||
}
|
||||
|
||||
type InventoryResult struct {
|
||||
*InventoryReference
|
||||
Quantity uint32
|
||||
}
|
||||
|
||||
type CartID string
|
||||
|
||||
type CartReserveRequest struct {
|
||||
*InventoryReference
|
||||
CartID CartID
|
||||
Quantity uint32
|
||||
TTL time.Duration
|
||||
}
|
||||
|
||||
// CartReservationService interface was removed in favor of
|
||||
// platform/inventory.ReservationPolicy. Consumers should depend on the
|
||||
// platform seam; the concrete *RedisCartReservationService implements its
|
||||
// methods directly.
|
||||
|
||||
type ReservationStatus struct {
|
||||
Active bool
|
||||
RemainingTime time.Duration
|
||||
}
|
||||
|
||||
type ReservationSummary struct {
|
||||
ReservationCount int64 `json:"reservation_count"`
|
||||
EarliestRelease time.Time `json:"earliest_release"`
|
||||
RemainingItems int64 `json:"remaining_items"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user