This commit is contained in:
2026-07-03 23:11:03 +02:00
parent 4a3c953045
commit ba60e22404
3 changed files with 43 additions and 35 deletions
+6 -5
View File
@@ -17,9 +17,10 @@
// listener.go subscribes to the inventory_changed Redis pub/sub channel // listener.go subscribes to the inventory_changed Redis pub/sub channel
// and mirrors upstream events into the local cache. // and mirrors upstream events into the local cache.
// //
// TODO: types.go mixes storage types (InventoryItem, InventoryReference) // Request and reservation DTOs (CartReserveRequest, ReserveRequest,
// with request types (CartReserveRequest, ReserveRequest). Split into // CartID, ReservationStatus, ReservationSummary) now live in
// `types/storage.go` and `types/cart.go` so callers can depend on only // request_types.go. Storage types (InventoryItem, InventoryReference,
// what they need. Start by moving CartReserveRequest + ReserveRequest to // InventoryResult) remain in types.go. When adding a new request shape,
// `types/cart.go` and adjusting the imports in cmd/*. // put it in request_types.go; when adding a new storage shape, put it
// in types.go.
package inventory package inventory
+37
View File
@@ -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"`
}
-30
View File
@@ -33,37 +33,7 @@ type InventoryService interface {
ReservationCheck(ctx context.Context, req ...ReserveRequest) (*ReserveRequest, error) ReservationCheck(ctx context.Context, req ...ReserveRequest) (*ReserveRequest, error)
} }
type ReserveRequest struct {
*InventoryReference
Quantity uint32
}
type InventoryResult struct { type InventoryResult struct {
*InventoryReference *InventoryReference
Quantity uint32 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"`
}