This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Make sure that Postgres is running, then run Kong, and finally run Konga | |
#----------------------------------------------------------------| | |
# 1. Create Network: | | |
#----------------------------------------------------------------| | |
sudo docker network create {NETWORK} | |
#----------------------------------------------------------------| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateOrderStageHandler implements Stage<CreateOrderCommand, String> { | |
private String process(CreateOrderCommand order) { | |
// Get shopper account Id | |
var shopperId = accountRepository.getAccountId(order.shopperName); | |
// Delete item from shopper's cart | |
cartRepository.deleteShopperItem(shopperId, order.item); | |
// Add the order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the API Controller | |
// ... | |
public String createOrder(CreateOrderCommand order) { | |
// ... | |
var orderCreationResult = new Pipeline<>(new CreateOrderStageHandler(order)); | |
return orderCreationResult; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Stage<I, O> { | |
O process(I input); | |
} | |
class Pipeline<I, O> { | |
private final Stage<I, O> currentStage; | |
Pipeline(Stage<I, O> currentStage) { | |
this.currentStage = currentStage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Data | |
public class CreateOrderCommand { | |
String item, shopperName; | |
int quantity; | |
} |