sales-api 디렉토리에서 Sales API를 확인할 수 있습니다.
데이터베이스 연결
show databases;
use junnn0021;
show table status;
describe <테이블이름>;
select <열이름> from <테이블이름>;
curl -X GET loaclhost:8080
{"product_id":"ecb20045-b0b8-11ed-8e89-069658f3b1c6","name":"부산도너츠","price":19900,"stock":3,"BIN_TO_UUID(factory_id)":"9d2b8119-b0b8-11ed-8e89-069658f3b1c6","BIN_TO_UUID(ad_id)":"9fcfd19d-b0b8-11ed-8e89-069658f3b1c6"}
curl -X POST localhost:8080/checkout
{"message":"구매 완료 ! 남은 재고 : 2"}
{"message":"구매 완료 ! 남은 재고 : 1"}
{"message":"구매 완료 ! 남은 재고 : 0"}
{"message":"구매 실패! 남은 재고: 0"}
curl -X POST https://aklbebq5rk.execute-api.ap-northeast-2.amazonaws.com/checkout
{"message":"구매 실패! 남은 재고: 0"}
가용성을 높이기 위한 DLQ를 stock_queue에 연결
stock_queue에 들어온 메세지를 소모하기 위한 stock_lambda 구성
module.exports.hello = async (event) => {
await delay(15000)
console.log(event)
return event
}
function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
module.exports.hello = async (event) => {
await delay(15000)
console.log(event)
return event
}