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

Side by Side 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: skip testing for context Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « go/Goopfile.lock ('k') | go/src/infra/gae/libs/context/context.infra_testing » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // +build appengine
6
7 package context
8
9 import (
10 "appengine"
11 "appengine/datastore"
12
13 "github.com/mjibson/goon"
14
15 "infra/libs/logging"
16 )
17
18 /// Kinds + Keys
19
20 type Kinder interface {
21 Kind(src interface{}) string
22 }
23
24 type KindSetter interface {
25 KindNameResolver() goon.KindNameResolver
26 SetKindNameResolver(goon.KindNameResolver)
27 }
28
29 type NewKeyer interface {
30 NewKey(kind, stringID string, intID int64, parent *datastore.Key) *datas tore.Key
31 NewKeyObj(src interface{}) *datastore.Key
32 NewKeyObjError(src interface{}) (*datastore.Key, error)
33 }
34
35 type KindKeyer interface {
36 Kinder
37 NewKeyer
38 }
39
40 /// Read + Write
41
42 type SingleReadWriter interface {
43 Put(src interface{}) (*datastore.Key, error)
44 Get(dst interface{}) error
45 Delete(key *datastore.Key) error
46 }
47
48 type MultiReadWriter interface {
49 SingleReadWriter
50 DeleteMulti(keys []*datastore.Key) error
51 GetMulti(dst interface{}) error
52 PutMulti(src interface{}) ([]*datastore.Key, error)
53 }
54
55 /// Queries
56
57 type Queryer interface {
58 Run(q *datastore.Query) Iterator
59 GetAll(q *datastore.Query, dst interface{}) ([]*datastore.Key, error)
60 Count(q *datastore.Query) (int, error)
61 }
62
63 type Iterator interface {
64 Cursor() (datastore.Cursor, error)
65 Next(dst interface{}) (*datastore.Key, error)
66 }
67
68 /// Transactions
69
70 type Transactioner interface {
71 RunInTransaction(f func(c Context) error, opts *datastore.TransactionOpt ions) error
72 }
73
74 /// Abstraction breaking!
75
76 type DangerousContexter interface {
77 Context() appengine.Context
78 }
79
80 type SingleContext interface {
81 logging.Logger
82 Kinder
83 NewKeyer
84 SingleReadWriter
85 }
86
87 type Context interface {
88 logging.Logger
89 Kinder
90 NewKeyer
91 MultiReadWriter
92 Queryer
93 KindSetter
94 }
95
96 type TransactionerContext interface {
97 Context
98 Transactioner
99 }
100
101 type DangerousContext interface {
102 DangerousContexter
103 Context
104 }
105
106 type DangerousTransactionerContext interface {
107 DangerousContexter
108 TransactionerContext
109 }
OLDNEW
« no previous file with comments | « go/Goopfile.lock ('k') | go/src/infra/gae/libs/context/context.infra_testing » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698