only after mutations
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user