testing promotion actions
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"git.tornberg.me/go-cart-actor/pkg/cart"
|
||||
"git.tornberg.me/go-cart-actor/pkg/discovery"
|
||||
messages "git.tornberg.me/go-cart-actor/pkg/messages"
|
||||
"git.tornberg.me/go-cart-actor/pkg/promotions"
|
||||
"git.tornberg.me/go-cart-actor/pkg/proxy"
|
||||
"git.tornberg.me/go-cart-actor/pkg/voucher"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@@ -108,7 +109,25 @@ func main() {
|
||||
|
||||
controlPlaneConfig := actor.DefaultServerConfig()
|
||||
|
||||
promotionData, err := promotions.LoadStateFile("data/promotions.json")
|
||||
if err != nil {
|
||||
log.Printf("Error loading promotions: %v\n", err)
|
||||
}
|
||||
|
||||
promotionService := promotions.NewPromotionService(nil)
|
||||
|
||||
reg := cart.NewCartMultationRegistry()
|
||||
reg.RegisterProcessor(actor.NewMutationProcessor(func(g *cart.CartGrain) error {
|
||||
ctx := promotions.NewContextFromCart(g)
|
||||
_, actions := promotionService.EvaluateAll(promotionData.State.Promotions, ctx)
|
||||
for _, action := range actions {
|
||||
log.Printf("apply: %V", action)
|
||||
}
|
||||
return nil
|
||||
}), actor.NewMutationProcessor(func(g *cart.CartGrain) error {
|
||||
g.UpdateTotals()
|
||||
return nil
|
||||
}))
|
||||
diskStorage := actor.NewDiskStorage[cart.CartGrain]("data", reg)
|
||||
poolConfig := actor.GrainPoolConfig[cart.CartGrain]{
|
||||
MutationRegistry: reg,
|
||||
@@ -323,19 +342,7 @@ func main() {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
}
|
||||
log.Printf("Klarna order validation: %s", order.ID)
|
||||
//err = confirmOrder(order, orderHandler)
|
||||
//if err != nil {
|
||||
// log.Printf("Error validating order: %v\n", err)
|
||||
// w.WriteHeader(http.StatusInternalServerError)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//err = triggerOrderCompleted(err, syncedServer, order)
|
||||
//if err != nil {
|
||||
// log.Printf("Error processing cart message: %v\n", err)
|
||||
// w.WriteHeader(http.StatusInternalServerError)
|
||||
// return
|
||||
//}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user