package name.webdizz.fault.tolerance.gateway.endpoint;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.AllArgsConstructor;
import lombok.Data;
import name.webdizz.fault.tolerance.inventory.client.InventoryRequester;
import name.webdizz.fault.tolerance.inventory.client.command.TimeOutInventoryRequestCommand;
import name.webdizz.fault.tolerance.inventory.domain.Inventory;
import name.webdizz.fault.tolerance.inventory.domain.Product;
import name.webdizz.fault.tolerance.inventory.domain.Store;

@RestController
@RequestMapping("/api/products")
public class ProductDetailsEndpoint {

    private final InventoryRequester inventoryRequester;

    @Autowired
    public ProductDetailsEndpoint(final InventoryRequester inventoryRequester) {
        this.inventoryRequester = inventoryRequester;
    }

    @RequestMapping("/{store}/{product}")
    public ProductDetails inventory(@PathVariable("store") String storeId, @PathVariable("product") String productId) {
        Store store = new Store(storeId);
        Product product = new Product(productId);
        Inventory inventory = new TimeOutInventoryRequestCommand(inventoryRequester, store, product, 1000).execute();
        return new ProductDetails(inventory);
    }

    @Data
    @AllArgsConstructor
    class ProductDetails {
        private Inventory inventory;
    }
}

@@ -487,23 +487,30 @@
 command.
-TimeOut
+CircuitBreaker
 Inventor
@@ -1308,15 +1308,22 @@
 new 
-TimeOut
+CircuitBreaker
 Inve
@@ -1382,12 +1382,13 @@
 ct, 
-1000
+false
 ).ex

Switch to another command to call inventory service