| 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 prod | 5 package prod |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "github.com/luci/gae/service/module" | 8 "github.com/luci/gae/service/module" |
| 9 "golang.org/x/net/context" | 9 "golang.org/x/net/context" |
| 10 aeModule "google.golang.org/appengine/module" | 10 aeModule "google.golang.org/appengine/module" |
| 11 ) | 11 ) |
| 12 | 12 |
| 13 // useModule adds a Module implementation to context. | 13 // useModule adds a Module implementation to context. |
| 14 func useModule(usrCtx context.Context) context.Context { | 14 func useModule(usrCtx context.Context) context.Context { |
| 15 » return module.SetFactory(usrCtx, func(ci context.Context) module.Interfa
ce { | 15 » return module.SetFactory(usrCtx, func(ci context.Context) module.RawInte
rface { |
| 16 » » return modImpl{ci, AEContext(ci)} | 16 » » return modImpl{AEContext(ci)} |
| 17 }) | 17 }) |
| 18 } | 18 } |
| 19 | 19 |
| 20 type modImpl struct { | 20 type modImpl struct { |
| 21 » usrCtx context.Context | 21 » aeCtx context.Context |
| 22 » aeCtx context.Context | |
| 23 } | 22 } |
| 24 | 23 |
| 25 func (m modImpl) List() ([]string, error) { | 24 func (m modImpl) List() ([]string, error) { |
| 26 return aeModule.List(m.aeCtx) | 25 return aeModule.List(m.aeCtx) |
| 27 } | 26 } |
| 28 | 27 |
| 29 func (m modImpl) NumInstances(module, version string) (int, error) { | 28 func (m modImpl) NumInstances(module, version string) (int, error) { |
| 30 return aeModule.NumInstances(m.aeCtx, module, version) | 29 return aeModule.NumInstances(m.aeCtx, module, version) |
| 31 } | 30 } |
| 32 | 31 |
| 33 func (m modImpl) SetNumInstances(module, version string, instances int) error { | 32 func (m modImpl) SetNumInstances(module, version string, instances int) error { |
| 34 return aeModule.SetNumInstances(m.aeCtx, module, version, instances) | 33 return aeModule.SetNumInstances(m.aeCtx, module, version, instances) |
| 35 } | 34 } |
| 36 | 35 |
| 37 func (m modImpl) Versions(module string) ([]string, error) { | 36 func (m modImpl) Versions(module string) ([]string, error) { |
| 38 return aeModule.Versions(m.aeCtx, module) | 37 return aeModule.Versions(m.aeCtx, module) |
| 39 } | 38 } |
| 40 | 39 |
| 41 func (m modImpl) DefaultVersion(module string) (string, error) { | 40 func (m modImpl) DefaultVersion(module string) (string, error) { |
| 42 return aeModule.DefaultVersion(m.aeCtx, module) | 41 return aeModule.DefaultVersion(m.aeCtx, module) |
| 43 } | 42 } |
| 44 | 43 |
| 45 func (m modImpl) Start(module, version string) error { | 44 func (m modImpl) Start(module, version string) error { |
| 46 return aeModule.Start(m.aeCtx, module, version) | 45 return aeModule.Start(m.aeCtx, module, version) |
| 47 } | 46 } |
| 48 | 47 |
| 49 func (m modImpl) Stop(module, version string) error { | 48 func (m modImpl) Stop(module, version string) error { |
| 50 return aeModule.Stop(m.aeCtx, module, version) | 49 return aeModule.Stop(m.aeCtx, module, version) |
| 51 } | 50 } |
| OLD | NEW |