only after mutations
This commit is contained in:
@@ -117,14 +117,16 @@ func main() {
|
||||
promotionService := promotions.NewPromotionService(nil)
|
||||
|
||||
reg := cart.NewCartMultationRegistry()
|
||||
reg.RegisterProcessor(actor.NewMutationProcessor(func(g *cart.CartGrain) error {
|
||||
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 {
|
||||
}),
|
||||
actor.NewMutationProcessor(func(g *cart.CartGrain) error {
|
||||
g.UpdateTotals()
|
||||
return nil
|
||||
}))
|
||||
|
||||
@@ -225,12 +225,14 @@ func (r *ProtoMutationRegistry) Apply(grain any, msg ...proto.Message) ([]ApplyR
|
||||
results = append(results, ApplyResult{Error: err, Type: rt.Name(), Mutation: m})
|
||||
}
|
||||
|
||||
if len(results) > 0 {
|
||||
for _, processor := range r.processors {
|
||||
err := processor.Process(grain)
|
||||
if err != nil {
|
||||
return results, err
|
||||
}
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user