Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Unified Diff: go/src/infra/gae/libs/wrapper/memory/key.go

Issue 1143053004: Simplify memory package interface. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: switch to blasters Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: go/src/infra/gae/libs/wrapper/memory/key.go
diff --git a/go/src/infra/gae/libs/wrapper/memory/key.go b/go/src/infra/gae/libs/wrapper/memory/key.go
index 17e7387890c8ab06c85b0b9f412266848e00bae3..780efa99fd7a1f9391dd46e388171f56473790bf 100644
--- a/go/src/infra/gae/libs/wrapper/memory/key.go
+++ b/go/src/infra/gae/libs/wrapper/memory/key.go
@@ -176,23 +176,23 @@ func rootKey(key *datastore.Key) *datastore.Key {
type keyValidOption bool
const (
- // UserKeyOnly is used with KeyValid, and ensures that the key is only one
+ // userKeyOnly is used with keyValid, and ensures that the key is only one
// that's valid for a user program to write to.
- UserKeyOnly keyValidOption = false
+ userKeyOnly keyValidOption = false
- // AllowSpecialKeys is used with KeyValid, and allows keys for special
+ // allowSpecialKeys is used with keyValid, and allows keys for special
// metadata objects (like "__entity_group__").
- AllowSpecialKeys = true
+ allowSpecialKeys = true
)
-// KeyValid checks to see if a key is valid by applying a bunch of constraint
+// keyValid checks to see if a key is valid by applying a bunch of constraint
// rules to it (e.g. can't have StringID and IntID set at the same time, can't
// have a parent key which is Incomplete(), etc.)
//
// It verifies that the key is also in the provided namespace. It can also
// reject keys which are 'special' e.g. have a Kind starting with "__". This
// behavior is controllable with opt.
-func KeyValid(ns string, k *datastore.Key, opt keyValidOption) bool {
+func keyValid(ns string, k *datastore.Key, opt keyValidOption) bool {
// copied from the appengine SDK because why would any user program need to
// see if a key is valid? /s
if k == nil {
@@ -203,7 +203,7 @@ func KeyValid(ns string, k *datastore.Key, opt keyValidOption) bool {
return false
}
for ; k != nil; k = k.Parent() {
- if opt == UserKeyOnly && len(k.Kind()) >= 2 && k.Kind()[:2] == "__" { // reserve all Kinds starting with __
+ if opt == userKeyOnly && len(k.Kind()) >= 2 && k.Kind()[:2] == "__" { // reserve all Kinds starting with __
return false
}
if k.Kind() == "" || k.AppID() == "" {
@@ -224,13 +224,13 @@ func KeyValid(ns string, k *datastore.Key, opt keyValidOption) bool {
return true
}
-// KeyCouldBeValid is like KeyValid, but it allows for the possibility that the
+// keyCouldBeValid is like keyValid, but it allows for the possibility that the
// last token of the key is Incomplete(). It returns true if the Key will become
// valid once it recieves an automatically-assigned ID.
-func KeyCouldBeValid(ns string, k *datastore.Key, opt keyValidOption) bool {
+func keyCouldBeValid(ns string, k *datastore.Key, opt keyValidOption) bool {
// adds an id to k if it's incomplete.
if k.Incomplete() {
k = newKey(ns, k.Kind(), "", 1, k.Parent())
}
- return KeyValid(ns, k, opt)
+ return keyValid(ns, k, opt)
}
« no previous file with comments | « go/src/infra/gae/libs/wrapper/memory/globalinfo.go ('k') | go/src/infra/gae/libs/wrapper/memory/key_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698