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

Side by Side Diff: go/src/infra/gae/libs/context/context.go

Issue 1151473003: Better attempt at an appengine wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: fix coverage numbers 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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/luci/luci-go/common/logging"
14 "github.com/mjibson/goon"
15 )
16
17 /// Kinds + Keys
18
19 type Kinder interface {
20 Kind(src interface{}) string
21 }
22
23 type KindSetter interface {
24 KindNameResolver() goon.KindNameResolver
25 SetKindNameResolver(goon.KindNameResolver)
26 }
27
28 type NewKeyer interface {
29 NewKey(kind, stringID string, intID int64, parent *datastore.Key) *datas tore.Key
30 NewKeyObj(src interface{}) *datastore.Key
31 NewKeyObjError(src interface{}) (*datastore.Key, error)
32 }
33
34 type KindKeyer interface {
35 Kinder
36 NewKeyer
37 }
38
39 /// Read + Write
40
41 type SingleReadWriter interface {
42 Put(src interface{}) (*datastore.Key, error)
43 Get(dst interface{}) error
44 Delete(key *datastore.Key) error
45 }
46
47 type MultiReadWriter interface {
48 SingleReadWriter
49 DeleteMulti(keys []*datastore.Key) error
50 GetMulti(dst interface{}) error
51 PutMulti(src interface{}) ([]*datastore.Key, error)
52 }
53
54 /// Queries
55
56 type Queryer interface {
57 Run(q *datastore.Query) Iterator
58 GetAll(q *datastore.Query, dst interface{}) ([]*datastore.Key, error)
59 Count(q *datastore.Query) (int, error)
60 }
61
62 type Iterator interface {
63 Cursor() (datastore.Cursor, error)
64 Next(dst interface{}) (*datastore.Key, error)
65 }
66
67 /// Transactions
68
69 type Transactioner interface {
70 RunInTransaction(f func(c Context) error, opts *datastore.TransactionOpt ions) error
71 }
72
73 /// Abstraction breaking!
74
75 type DangerousContexter interface {
76 Context() appengine.Context
77 }
78
79 type SingleContext interface {
80 logging.Logger
81 Kinder
82 NewKeyer
83 SingleReadWriter
84 }
85
86 type Context interface {
87 logging.Logger
88 Kinder
89 NewKeyer
90 MultiReadWriter
91 Queryer
92 KindSetter
93 }
94
95 type TransactionerContext interface {
96 Context
97 Transactioner
98 }
99
100 type DangerousContext interface {
101 DangerousContexter
102 Context
103 }
104
105 type DangerousTransactionerContext interface {
106 DangerousContexter
107 TransactionerContext
108 }
OLDNEW
« no previous file with comments | « no previous file | go/src/infra/gae/libs/context/context.infra_testing » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698