package inventory import ( "errors" "sync" ) type MemoryInventoryService struct { warehouses map[LocationID]*Warehouse mu sync.RWMutex } func NewMemoryInventoryService() *MemoryInventoryService { return &MemoryInventoryService{ warehouses: make(map[LocationID]*Warehouse), } } func (s *MemoryInventoryService) AddWarehouse(warehouse *Warehouse) { s.mu.Lock() defer s.mu.Unlock() s.warehouses[warehouse.ID] = warehouse } func (s *MemoryInventoryService) GetInventory(sku SKU, locationID LocationID) (*InventoryItem, error) { s.mu.RLock() defer s.mu.RUnlock() warehouse, ok := s.warehouses[locationID] if !ok { return nil, errors.New("warehouse not found") } for _, item := range warehouse.Inventory { if item.SKU == sku { return &item, nil } } return nil, errors.New("sku not found in warehouse") } func (s *MemoryInventoryService) ReserveInventory(req ...ReserveRequest) error { // We'll implement the reservation logic using Lua script execution here // For now, let's just return an error indicating it's not implemented return errors.New("reservation not implemented yet") }