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

Unified Diff: go/src/infra/gae/libs/context/context.go

Issue 981003003: Simple GAE/goon Context wrapper (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: fixed copyright :p Created 5 years, 10 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 | « go/Goopfile.lock ('k') | go/src/infra/gae/libs/context/doc.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/context/context.go
diff --git a/go/src/infra/gae/libs/context/context.go b/go/src/infra/gae/libs/context/context.go
new file mode 100644
index 0000000000000000000000000000000000000000..db901a8669b4e68e1e31a91bbdae0cca41ac068b
--- /dev/null
+++ b/go/src/infra/gae/libs/context/context.go
@@ -0,0 +1,109 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
Vadim Sh. 2015/03/06 02:54:27 I assume all the permutations are actually used do
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// +build appengine
+
+package context
+
+import (
+ "appengine"
+ "appengine/datastore"
+
+ "github.com/mjibson/goon"
+
+ "infra/libs/logging"
+)
+
+/// Kinds + Keys
+
+type Kinder interface {
+ Kind(src interface{}) string
+}
+
+type KindSetter interface {
+ KindNameResolver() goon.KindNameResolver
+ SetKindNameResolver(goon.KindNameResolver)
+}
+
+type NewKeyer interface {
+ NewKey(kind, stringID string, intID int64, parent *datastore.Key) *datastore.Key
+ NewKeyObj(src interface{}) *datastore.Key
+ NewKeyObjError(src interface{}) (*datastore.Key, error)
+}
+
+type KindKeyer interface {
+ Kinder
+ NewKeyer
+}
+
+/// Read + Write
+
+type SingleReadWriter interface {
+ Put(src interface{}) (*datastore.Key, error)
+ Get(dst interface{}) error
+ Delete(key *datastore.Key) error
+}
+
+type MultiReadWriter interface {
+ SingleReadWriter
+ DeleteMulti(keys []*datastore.Key) error
+ GetMulti(dst interface{}) error
+ PutMulti(src interface{}) ([]*datastore.Key, error)
+}
+
+/// Queries
+
+type Queryer interface {
+ Run(q *datastore.Query) Iterator
+ GetAll(q *datastore.Query, dst interface{}) ([]*datastore.Key, error)
+ Count(q *datastore.Query) (int, error)
+}
+
+type Iterator interface {
+ Cursor() (datastore.Cursor, error)
+ Next(dst interface{}) (*datastore.Key, error)
+}
+
+/// Transactions
+
+type Transactioner interface {
+ RunInTransaction(f func(c Context) error, opts *datastore.TransactionOptions) error
+}
+
+/// Abstraction breaking!
+
+type DangerousContexter interface {
+ Context() appengine.Context
+}
+
+type SingleContext interface {
+ logging.Logger
+ Kinder
+ NewKeyer
+ SingleReadWriter
+}
+
+type Context interface {
+ logging.Logger
+ Kinder
+ NewKeyer
+ MultiReadWriter
+ Queryer
+ KindSetter
+}
+
+type TransactionerContext interface {
+ Context
+ Transactioner
+}
+
+type DangerousContext interface {
+ DangerousContexter
+ Context
+}
+
+type DangerousTransactionerContext interface {
Vadim Sh. 2015/03/06 02:54:27 nit: maybe "FullContext" or "CompleteContext" or "
+ DangerousContexter
+ TransactionerContext
+}
« no previous file with comments | « go/Goopfile.lock ('k') | go/src/infra/gae/libs/context/doc.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698