Skip to content

Commit

Permalink
final cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tkeburia committed Dec 11, 2023
1 parent e7d8ab7 commit 113cd97
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import com.redbadger.orderservice.dto.OrderDto;
import com.redbadger.orderservice.dto.OrderRequest;
import com.redbadger.orderservice.service.OrderService;
import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import io.github.resilience4j.retry.annotation.Retry;
import io.github.resilience4j.timelimiter.annotation.TimeLimiter;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
Expand All @@ -22,9 +19,6 @@ public class OrderController {

@PostMapping
@ResponseStatus(HttpStatus.CREATED)
@CircuitBreaker(name = "inventory", fallbackMethod = "fallbackMethod")
@TimeLimiter(name = "inventory")
@Retry(name = "inventory")
public CompletableFuture<String> placeOrder(@RequestBody OrderRequest orderRequest) {
return CompletableFuture.supplyAsync(() -> orderService.placeOrder(orderRequest));
}
Expand All @@ -34,9 +28,4 @@ public CompletableFuture<String> placeOrder(@RequestBody OrderRequest orderReque
public List<OrderDto> getOrders() {
return orderService.getOrders();
}


public CompletableFuture<String> fallbackMethod(OrderRequest orderRequest, RuntimeException runtimeException) {
return CompletableFuture.supplyAsync(() -> "Oops! Something went wrong, please order after some time!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ public String placeOrder(OrderRequest orderRequest) {
boolean allProductsInStock = Arrays.stream(inventoryResponsArray)
.allMatch(InventoryResponse::isInStock) && inventoryResponsArray.length > 0;

System.out.println(Arrays.stream(inventoryResponsArray).toList());
System.out.println(allProductsInStock);

if (allProductsInStock) {
log.info("All requested products are in stock");
orderRepository.save(order);
Expand Down

0 comments on commit 113cd97

Please sign in to comment.