only after mutations
All checks were successful
Build and Publish / Metadata (push) Successful in 10s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m15s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m31s

This commit is contained in:
matst80
2025-10-20 21:09:45 +02:00
parent 9ecd91c163
commit 7eb000fd17
2 changed files with 19 additions and 15 deletions

View File

@@ -117,17 +117,19 @@ func main() {
promotionService := promotions.NewPromotionService(nil) promotionService := promotions.NewPromotionService(nil)
reg := cart.NewCartMultationRegistry() reg := cart.NewCartMultationRegistry()
reg.RegisterProcessor(actor.NewMutationProcessor(func(g *cart.CartGrain) error { reg.RegisterProcessor(
ctx := promotions.NewContextFromCart(g) actor.NewMutationProcessor(func(g *cart.CartGrain) error {
_, actions := promotionService.EvaluateAll(promotionData.State.Promotions, ctx) ctx := promotions.NewContextFromCart(g)
for _, action := range actions { _, actions := promotionService.EvaluateAll(promotionData.State.Promotions, ctx)
log.Printf("apply: %V", action) for _, action := range actions {
} log.Printf("apply: %V", action)
return nil }
}), actor.NewMutationProcessor(func(g *cart.CartGrain) error { return nil
g.UpdateTotals() }),
return nil actor.NewMutationProcessor(func(g *cart.CartGrain) error {
})) g.UpdateTotals()
return nil
}))
diskStorage := actor.NewDiskStorage[cart.CartGrain]("data", reg) diskStorage := actor.NewDiskStorage[cart.CartGrain]("data", reg)
poolConfig := actor.GrainPoolConfig[cart.CartGrain]{ poolConfig := actor.GrainPoolConfig[cart.CartGrain]{
MutationRegistry: reg, MutationRegistry: reg,

View File

@@ -225,10 +225,12 @@ func (r *ProtoMutationRegistry) Apply(grain any, msg ...proto.Message) ([]ApplyR
results = append(results, ApplyResult{Error: err, Type: rt.Name(), Mutation: m}) results = append(results, ApplyResult{Error: err, Type: rt.Name(), Mutation: m})
} }
for _, processor := range r.processors { if len(results) > 0 {
err := processor.Process(grain) for _, processor := range r.processors {
if err != nil { err := processor.Process(grain)
return results, err if err != nil {
return results, err
}
} }
} }
return results, nil return results, nil