public function send(Message $message) { $this->utilService->enterConcurrentSection('email', $this->maxPerSecond, 1); $this->incrementIndex(); $provider = $this->providers[$this->providerIndex]; $result = $provider->send($message); $this->utilService->exitConcurrentSection('email'); return $result; }
public function reserveProducts(Order $order) { $lockName = 'reserve_products'; $this->utilService->getLock($lockName); try { if ($this->checkProductsStock($order)) { $this->doReserveProducts($order); $this->eventDispatcher->dispatch(OrderEvent::PRODUCTS_RESERVED, new OrderEvent($order)); } else { $this->eventDispatcher->dispatch(OrderEvent::PRODUCTS_RESERVATION_FAILED, new OrderEvent($order)); } } finally { $this->utilService->releaseLock($lockName); } }