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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | filter/featureBreaker/gi.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 count
6
7 import (
8 "golang.org/x/net/context"
9
10 "github.com/luci/gae/service/module"
11 )
12
13 // ModuleCounter is the counter object for the Module service.
14 type ModuleCounter struct {
15 List Entry
16 NumInstances Entry
17 SetNumInstances Entry
18 Versions Entry
19 DefaultVersion Entry
20 Start Entry
21 Stop Entry
22 }
23
24 type modCounter struct {
25 c *ModuleCounter
26
27 mod module.Interface
28 }
29
30 var _ module.Interface = (*modCounter)(nil)
31
32 func (m *modCounter) List() ([]string, error) {
33 ret, err := m.mod.List()
34 return ret, m.c.List.up(err)
35 }
36
37 func (m *modCounter) NumInstances(mod, ver string) (int, error) {
38 ret, err := m.mod.NumInstances(mod, ver)
39 return ret, m.c.NumInstances.up(err)
40 }
41
42 func (m *modCounter) SetNumInstances(mod, ver string, instances int) error {
43 return m.c.SetNumInstances.up(m.mod.SetNumInstances(mod, ver, instances) )
44 }
45
46 func (m *modCounter) Versions(mod string) ([]string, error) {
47 ret, err := m.mod.Versions(mod)
48 return ret, m.c.Versions.up(err)
49 }
50
51 func (m *modCounter) DefaultVersion(mod string) (string, error) {
52 ret, err := m.mod.DefaultVersion(mod)
53 return ret, m.c.DefaultVersion.up(err)
54 }
55
56 func (m *modCounter) Start(mod, ver string) error {
57 return m.c.Start.up(m.mod.Start(mod, ver))
58 }
59
60 func (m *modCounter) Stop(mod, ver string) error {
61 return m.c.Stop.up(m.mod.Stop(mod, ver))
62 }
63
64 // FilterModule installs a counter Module filter in the context.
65 func FilterModule(c context.Context) (context.Context, *ModuleCounter) {
66 state := &ModuleCounter{}
67 return module.AddFilters(c, func(ic context.Context, mod module.Interfac e) module.Interface {
68 return &modCounter{state, mod}
69 }), state
70 }
OLDNEW
« 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