change ids
This commit is contained in:
22
main.go
22
main.go
@@ -72,7 +72,7 @@ func (a *App) Save() error {
|
||||
if grain == nil {
|
||||
continue
|
||||
}
|
||||
if grain.GetLastChange() > a.storage.LastSaves[id] {
|
||||
if grain.GetLastChange() > a.storage.LastSaves[uint64(id)] {
|
||||
hasChanges = true
|
||||
err := a.storage.Store(id, grain)
|
||||
if err != nil {
|
||||
@@ -160,12 +160,12 @@ func GetDiscovery() Discovery {
|
||||
|
||||
func main() {
|
||||
|
||||
storage, err := NewDiskStorage(fmt.Sprintf("data/%s_state.gob", name))
|
||||
storage, err := NewDiskStorage(fmt.Sprintf("data/s_%s.gob", name))
|
||||
if err != nil {
|
||||
log.Printf("Error loading state: %v\n", err)
|
||||
}
|
||||
app := &App{
|
||||
pool: NewGrainLocalPool(65535, 2*time.Hour, spawn),
|
||||
pool: NewGrainLocalPool(65535, 15*time.Minute, spawn),
|
||||
storage: storage,
|
||||
}
|
||||
|
||||
@@ -253,7 +253,13 @@ func main() {
|
||||
w.Write([]byte("no cart id to checkout is empty"))
|
||||
return
|
||||
}
|
||||
cartId := ToCartId(cookie.Value)
|
||||
parsed, ok := ParseCartId(cookie.Value)
|
||||
if !ok {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write([]byte("invalid cart id format"))
|
||||
return
|
||||
}
|
||||
cartId := parsed
|
||||
order, err = syncedServer.CreateOrUpdateCheckout(r.Host, cartId)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
@@ -393,9 +399,13 @@ func triggerOrderCompleted(err error, syncedServer *PoolServer, order *CheckoutO
|
||||
OrderId: order.ID,
|
||||
Status: order.Status,
|
||||
}
|
||||
_, applyErr := syncedServer.pool.Apply(ToCartId(order.MerchantReference1), mutation)
|
||||
cid, ok := ParseCartId(order.MerchantReference1)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid cart id in order reference: %s", order.MerchantReference1)
|
||||
}
|
||||
_, applyErr := syncedServer.pool.Apply(cid, mutation)
|
||||
if applyErr == nil {
|
||||
_ = AppendCartEvent(ToCartId(order.MerchantReference1), mutation)
|
||||
_ = AppendCartEvent(cid, mutation)
|
||||
}
|
||||
return applyErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user