Update checkout_server.go
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"git.tornberg.me/go-cart-actor/pkg/actor"
|
||||
"git.tornberg.me/go-cart-actor/pkg/cart"
|
||||
"git.tornberg.me/go-cart-actor/pkg/messages"
|
||||
"git.tornberg.me/mats/go-redis-inventory/pkg/inventory"
|
||||
amqp "github.com/rabbitmq/amqp091-go"
|
||||
)
|
||||
@@ -84,11 +85,16 @@ func (a *App) HandleCheckoutRequests(amqpUrl string, mux *http.ServeMux, invento
|
||||
if inventoryService != nil {
|
||||
inventoryRequests := getInventoryRequests(grain.Items)
|
||||
err = inventoryService.ReserveInventory(r.Context(), inventoryRequests...)
|
||||
|
||||
if err != nil {
|
||||
logger.WarnContext(r.Context(), "placeorder inventory reservation failed")
|
||||
w.WriteHeader(http.StatusNotAcceptable)
|
||||
return
|
||||
}
|
||||
a.pool.Apply(r.Context(), uint64(grain.Id), &messages.InventoryReserved{
|
||||
Id: grain.Id.String(),
|
||||
Status: "success",
|
||||
})
|
||||
}
|
||||
|
||||
err = confirmOrder(r.Context(), order, orderHandler)
|
||||
|
||||
Reference in New Issue
Block a user