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