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

Unified Diff: filter/count/mod.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 | « no previous file | filter/featureBreaker/gi.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/count/mod.go
diff --git a/filter/count/mod.go b/filter/count/mod.go
new file mode 100644
index 0000000000000000000000000000000000000000..8551dc23e4551f189ed1e6294192d6b3a301a64b
--- /dev/null
+++ b/filter/count/mod.go
@@ -0,0 +1,70 @@
+// Copyright 2015 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 count
+
+import (
+ "golang.org/x/net/context"
+
+ "github.com/luci/gae/service/module"
+)
+
+// ModuleCounter is the counter object for the Module service.
+type ModuleCounter struct {
+ List Entry
+ NumInstances Entry
+ SetNumInstances Entry
+ Versions Entry
+ DefaultVersion Entry
+ Start Entry
+ Stop Entry
+}
+
+type modCounter struct {
+ c *ModuleCounter
+
+ mod module.Interface
+}
+
+var _ module.Interface = (*modCounter)(nil)
+
+func (m *modCounter) List() ([]string, error) {
+ ret, err := m.mod.List()
+ return ret, m.c.List.up(err)
+}
+
+func (m *modCounter) NumInstances(mod, ver string) (int, error) {
+ ret, err := m.mod.NumInstances(mod, ver)
+ return ret, m.c.NumInstances.up(err)
+}
+
+func (m *modCounter) SetNumInstances(mod, ver string, instances int) error {
+ return m.c.SetNumInstances.up(m.mod.SetNumInstances(mod, ver, instances))
+}
+
+func (m *modCounter) Versions(mod string) ([]string, error) {
+ ret, err := m.mod.Versions(mod)
+ return ret, m.c.Versions.up(err)
+}
+
+func (m *modCounter) DefaultVersion(mod string) (string, error) {
+ ret, err := m.mod.DefaultVersion(mod)
+ return ret, m.c.DefaultVersion.up(err)
+}
+
+func (m *modCounter) Start(mod, ver string) error {
+ return m.c.Start.up(m.mod.Start(mod, ver))
+}
+
+func (m *modCounter) Stop(mod, ver string) error {
+ return m.c.Stop.up(m.mod.Stop(mod, ver))
+}
+
+// FilterModule installs a counter Module filter in the context.
+func FilterModule(c context.Context) (context.Context, *ModuleCounter) {
+ state := &ModuleCounter{}
+ return module.AddFilters(c, func(ic context.Context, mod module.Interface) module.Interface {
+ return &modCounter{state, mod}
+ }), state
+}
« no previous file with comments | « no previous file | filter/featureBreaker/gi.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698