OLD | NEW |
1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package cloud | 5 package cloud |
6 | 6 |
7 import ( | 7 import ( |
8 "github.com/luci/gae/impl/dummy" | 8 "github.com/luci/gae/impl/dummy" |
9 ds "github.com/luci/gae/service/datastore" | 9 ds "github.com/luci/gae/service/datastore" |
10 "github.com/luci/gae/service/mail" | 10 "github.com/luci/gae/service/mail" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Dummy services that we don't support. | 44 // Dummy services that we don't support. |
45 c = mail.Set(c, dummy.Mail()) | 45 c = mail.Set(c, dummy.Mail()) |
46 c = module.Set(c, dummy.Module()) | 46 c = module.Set(c, dummy.Module()) |
47 c = taskqueue.SetRaw(c, dummy.TaskQueue()) | 47 c = taskqueue.SetRaw(c, dummy.TaskQueue()) |
48 c = user.Set(c, dummy.User()) | 48 c = user.Set(c, dummy.User()) |
49 | 49 |
50 c = useInfo(c) | 50 c = useInfo(c) |
51 | 51 |
52 // datastore service | 52 // datastore service |
53 if cfg.DS != nil { | 53 if cfg.DS != nil { |
54 » » cds := cloudDatastore{ | 54 » » c = UseDatastore(c, cfg.DS) |
55 » » » client: cfg.DS, | |
56 » » } | |
57 » » c = cds.use(c) | |
58 } else { | 55 } else { |
59 c = ds.SetRaw(c, dummy.Datastore()) | 56 c = ds.SetRaw(c, dummy.Datastore()) |
60 } | 57 } |
61 | 58 |
62 // memcache service | 59 // memcache service |
63 if cfg.MC != nil { | 60 if cfg.MC != nil { |
64 mc := memcacheClient{ | 61 mc := memcacheClient{ |
65 client: cfg.MC, | 62 client: cfg.MC, |
66 } | 63 } |
67 c = mc.use(c) | 64 c = mc.use(c) |
68 } else { | 65 } else { |
69 c = mc.SetRaw(c, dummy.Memcache()) | 66 c = mc.SetRaw(c, dummy.Memcache()) |
70 } | 67 } |
71 | 68 |
72 return c | 69 return c |
73 } | 70 } |
| 71 |
| 72 // UseDatastore installs a datastore implementation into the context. |
| 73 func UseDatastore(c context.Context, client *datastore.Client) context.Context { |
| 74 cds := cloudDatastore{ |
| 75 client: client, |
| 76 } |
| 77 return cds.use(c) |
| 78 } |
OLD | NEW |