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

Unified Diff: service/rawdatastore/interface.go

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint Created 5 years, 5 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
« no previous file with comments | « service/rawdatastore/generic_key.go ('k') | service/rawdatastore/internal/protos/datastore/README.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/rawdatastore/interface.go
diff --git a/service/rawdatastore/interface.go b/service/rawdatastore/interface.go
new file mode 100644
index 0000000000000000000000000000000000000000..0764031d1daeecd31ea004df681794aeb0fee2b4
--- /dev/null
+++ b/service/rawdatastore/interface.go
@@ -0,0 +1,86 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package rawdatastore
+
+import (
+ "fmt"
+
+ "golang.org/x/net/context"
+)
+
+/// Kinds + Keys
+
+// Key is the equivalent of *datastore.Key from the original SDK, except that
+// it can have multiple implementations. See helper.Key* methods for missing
+// methods like KeyIncomplete (and some new ones like KeyValid).
+type Key interface {
+ Kind() string
+ StringID() string
+ IntID() int64
+ Parent() Key
+ AppID() string
+ Namespace() string
+
+ String() string
+}
+
+// KeyTok is a single token from a multi-part Key.
+type KeyTok struct {
+ Kind string
+ IntID int64
+ StringID string
+}
+
+// Cursor wraps datastore.Cursor.
+type Cursor interface {
+ fmt.Stringer
+}
+
+// Query wraps datastore.Query.
+type Query interface {
+ Ancestor(ancestor Key) Query
+ Distinct() Query
+ End(c Cursor) Query
+ EventualConsistency() Query
+ Filter(filterStr string, value interface{}) Query
+ KeysOnly() Query
+ Limit(limit int) Query
+ Offset(offset int) Query
+ Order(fieldName string) Query
+ Project(fieldNames ...string) Query
+ Start(c Cursor) Query
+}
+
+// Iterator wraps datastore.Iterator.
+type Iterator interface {
+ Cursor() (Cursor, error)
+ Next(dst PropertyLoadSaver) (Key, error)
+}
+
+// Interface implements the datastore functionality without any of the fancy
+// reflection stuff. This is so that Filters can avoid doing lots of redundant
+// reflection work. See helper.Datastore for a more user-friendly interface.
+type Interface interface {
+ NewKey(kind, stringID string, intID int64, parent Key) Key
+ DecodeKey(encoded string) (Key, error)
+
+ NewQuery(kind string) Query
+ Count(q Query) (int, error)
+
+ RunInTransaction(f func(c context.Context) error, opts *TransactionOptions) error
+
+ Run(q Query) Iterator
+ GetAll(q Query, dst *[]PropertyMap) ([]Key, error)
+
+ Put(key Key, src PropertyLoadSaver) (Key, error)
+ Get(key Key, dst PropertyLoadSaver) error
+ Delete(key Key) error
+
+ // These allow you to read and write a multiple datastore objects in
+ // a non-atomic batch.
+ DeleteMulti(keys []Key) error
+ GetMulti(keys []Key, dst []PropertyLoadSaver) error
+ PutMulti(keys []Key, src []PropertyLoadSaver) ([]Key, error)
+}
« no previous file with comments | « service/rawdatastore/generic_key.go ('k') | service/rawdatastore/internal/protos/datastore/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698