some strange storage stuff
Some checks failed
Build and Publish / Metadata (push) Successful in 4s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 48s
Build and Publish / BuildAndDeployArm64 (push) Failing after 26m40s

This commit is contained in:
matst80
2025-10-10 19:31:06 +00:00
parent fb111ebf97
commit 7814f33a06
5 changed files with 339 additions and 15 deletions

25
main.go
View File

@@ -43,11 +43,16 @@ func spawn(id CartId) (*CartGrain, error) {
Deliveries: []*CartDelivery{},
Id: id,
Items: []*CartItem{},
// storageMessages removed (legacy event log deprecated)
TotalPrice: 0,
TotalPrice: 0,
}
err := loadMessages(ret, id)
return ret, err
// Set baseline lastChange at spawn; replay may update it to last event timestamp.
ret.lastChange = time.Now().Unix()
// Legacy loadMessages (no-op) retained; then replay append-only event log
_ = loadMessages(ret, id)
_ = ReplayCartEvents(ret, id)
return ret, nil
}
func init() {
@@ -160,7 +165,7 @@ func main() {
log.Printf("Error loading state: %v\n", err)
}
app := &App{
pool: NewGrainLocalPool(65535, 5*time.Minute, spawn),
pool: NewGrainLocalPool(65535, 2*time.Hour, spawn),
storage: storage,
}
@@ -384,11 +389,15 @@ func main() {
}
func triggerOrderCompleted(err error, syncedServer *PoolServer, order *CheckoutOrder) error {
_, err = syncedServer.pool.Apply(ToCartId(order.MerchantReference1), &messages.OrderCreated{
mutation := &messages.OrderCreated{
OrderId: order.ID,
Status: order.Status,
})
return err
}
_, applyErr := syncedServer.pool.Apply(ToCartId(order.MerchantReference1), mutation)
if applyErr == nil {
_ = AppendCartEvent(ToCartId(order.MerchantReference1), mutation)
}
return applyErr
}
func confirmOrder(order *CheckoutOrder, orderHandler *AmqpOrderHandler) error {