| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package memory | 5 package memory |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "sync" | 10 "sync" |
| 11 "sync/atomic" | 11 "sync/atomic" |
| 12 | 12 |
| 13 ds "github.com/luci/gae/service/datastore" | 13 ds "github.com/luci/gae/service/datastore" |
| 14 "github.com/luci/gae/service/datastore/dskey" | 14 "github.com/luci/gae/service/datastore/dskey" |
| 15 "github.com/luci/gae/service/datastore/serialize" | 15 "github.com/luci/gae/service/datastore/serialize" |
| 16 "github.com/luci/luci-go/common/errors" | 16 "github.com/luci/luci-go/common/errors" |
| 17 "golang.org/x/net/context" | 17 "golang.org/x/net/context" |
| 18 ) | 18 ) |
| 19 | 19 |
| 20 //////////////////////////////// dataStoreData ///////////////////////////////// | 20 //////////////////////////////// dataStoreData ///////////////////////////////// |
| 21 | 21 |
| 22 type dataStoreData struct { | 22 type dataStoreData struct { |
| 23 rwlock sync.RWMutex | 23 rwlock sync.RWMutex |
| 24 // See README.md for head schema. | 24 // See README.md for head schema. |
| 25 head *memStore | 25 head *memStore |
| 26 snap *memStore | 26 snap *memStore |
| 27 // For testing, see SetTransactionRetryCount. |
| 28 txnFakeRetry int |
| 27 } | 29 } |
| 28 | 30 |
| 29 var ( | 31 var ( |
| 30 _ = memContextObj((*dataStoreData)(nil)) | 32 _ = memContextObj((*dataStoreData)(nil)) |
| 31 _ = sync.Locker((*dataStoreData)(nil)) | 33 _ = sync.Locker((*dataStoreData)(nil)) |
| 32 ) | 34 ) |
| 33 | 35 |
| 34 func newDataStoreData() *dataStoreData { | 36 func newDataStoreData() *dataStoreData { |
| 35 head := newMemStore() | 37 head := newMemStore() |
| 36 return &dataStoreData{ | 38 return &dataStoreData{ |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 432 } |
| 431 | 433 |
| 432 func rpm(data []byte) (ds.PropertyMap, error) { | 434 func rpm(data []byte) (ds.PropertyMap, error) { |
| 433 return serialize.ReadPropertyMap(bytes.NewBuffer(data), | 435 return serialize.ReadPropertyMap(bytes.NewBuffer(data), |
| 434 serialize.WithContext, "", "") | 436 serialize.WithContext, "", "") |
| 435 } | 437 } |
| 436 | 438 |
| 437 type keyitem interface { | 439 type keyitem interface { |
| 438 Key() ds.Key | 440 Key() ds.Key |
| 439 } | 441 } |
| OLD | NEW |