OLD | NEW |
(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 // Package gae provides a fakable wrapped interface for the appengine SDK's |
| 6 // APIs. This means that it's possible to mock all of the supported appengine |
| 7 // APIs for testing (or potentially implement a different backend for them). |
| 8 // |
| 9 // gae currently provides interfaces for: |
| 10 // * Datastore |
| 11 // * Memcache |
| 12 // * TaskQueue |
| 13 // * GlobalInfo (e.g. Namespace, AppID, etc.) |
| 14 // |
| 15 // A package which implements the gae is expected to provide the following: |
| 16 // * A package function `Enable(c context.Context, ...) context.Context` |
| 17 // This function is expected to add any information to c which is necessary |
| 18 // for the rest of its implementations to work. This may be something like |
| 19 // an `appengine.Context` or some connection information for an external |
| 20 // server. The `...` in the function signature may be any additional data |
| 21 // needed. |
| 22 // * Any of the package functions: |
| 23 // |
| 24 // UseDS(context.Context) context.Context |
| 25 // UseMC(context.Context) context.Context |
| 26 // UseTQ(context.Context) context.Context |
| 27 // UseGI(context.Context) context.Context |
| 28 // |
| 29 // each of which would call gae.Set<service>Factory with the factory |
| 30 // function for that interface type. |
| 31 // * A `Use(context.Context) context.Context` function which calls all of
the |
| 32 // `Use*` package functions implemented by the package. |
| 33 // * Partially-implemented interfaces should embed one of the Dummy* structs |
| 34 // which will panic with an appropriate error for unimplemented |
| 35 // methods. |
| 36 // |
| 37 // see "infra/gae/libs/gae/oldsdk" for an appengine-backed implementation. |
| 38 // |
| 39 // Datastore struct serialization uses the tag name 'gae' instead of 'datastore'
, |
| 40 // and uses gae.DSKey but otherwise behaves identically. You must use the |
| 41 // new-SDK primitive types (like GeoPoint, ByteString, etc.), even when using |
| 42 // the old-SDK implementation of the factories. This was done to ensure that all |
| 43 // code written against gae is go-gettable, and was deemed as less-annoying than |
| 44 // re-defining all of the types identically. |
| 45 // |
| 46 // Kinds/Keys work similarly to how they work in goon (except you no longer use |
| 47 // the goon + datastore tags and key/control-related tags start with $): |
| 48 // |
| 49 // type FooModel struct { |
| 50 // _kind string `gae:"$kind,Foo"` |
| 51 // Id string `gae:"$id"` |
| 52 // Parent DSKey `gae:"$parent"` |
| 53 // |
| 54 // privateSkipped bool |
| 55 // AutoSave int |
| 56 // NoSaveField string `gae:"-"` |
| 57 // NoIndexField float `gae:",noindex"` |
| 58 // DiffName string `gae:"coolName"` |
| 59 // } |
| 60 // |
| 61 // func (FooModel) GetCachePolicy() DSCacheFlags { return DSCache } |
| 62 package gae |
OLD | NEW |