Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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
| |
| 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 { | |
|
Vadim Sh.
2015/03/06 02:54:27
nit: maybe "FullContext" or "CompleteContext" or "
| |
| 107 DangerousContexter | |
| 108 TransactionerContext | |
| 109 } | |
| OLD | NEW |