Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: impl/prod/module.go

Issue 1772943003: Add wrappers for the module module (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: CL comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/prod/context.go ('k') | service/module/context.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/prod/module.go
diff --git a/impl/prod/module.go b/impl/prod/module.go
new file mode 100644
index 0000000000000000000000000000000000000000..a2680be71db0fdd3f0a1a0058d0620bb167c98b2
--- /dev/null
+++ b/impl/prod/module.go
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package prod
+
+import (
+ "github.com/luci/gae/service/module"
+ "golang.org/x/net/context"
+ aeModule "google.golang.org/appengine/module"
+)
+
+// useModule adds a Module implementation to context.
+func useModule(usrCtx context.Context) context.Context {
+ return module.SetFactory(usrCtx, func(ci context.Context) module.Interface {
+ return modImpl{ci, AEContext(ci)}
+ })
+}
+
+type modImpl struct {
+ usrCtx context.Context
+ aeCtx context.Context
+}
+
+func (m modImpl) List() ([]string, error) {
+ return aeModule.List(m.aeCtx)
+}
+
+func (m modImpl) NumInstances(module, version string) (int, error) {
+ return aeModule.NumInstances(m.aeCtx, module, version)
+}
+
+func (m modImpl) SetNumInstances(module, version string, instances int) error {
+ return aeModule.SetNumInstances(m.aeCtx, module, version, instances)
+}
+
+func (m modImpl) Versions(module string) ([]string, error) {
+ return aeModule.Versions(m.aeCtx, module)
+}
+
+func (m modImpl) DefaultVersion(module string) (string, error) {
+ return aeModule.DefaultVersion(m.aeCtx, module)
+}
+
+func (m modImpl) Start(module, version string) error {
+ return aeModule.Start(m.aeCtx, module, version)
+}
+
+func (m modImpl) Stop(module, version string) error {
+ return aeModule.Stop(m.aeCtx, module, version)
+}
« no previous file with comments | « impl/prod/context.go ('k') | service/module/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698