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 module | 5 package module |
6 | 6 |
7 // Interface is the interface for all of the package methods which normally | 7 import ( |
| 8 » "golang.org/x/net/context" |
| 9 ) |
| 10 |
| 11 // RawInterface is the interface for all of the package methods which normally |
8 // would be in the 'module' package. | 12 // would be in the 'module' package. |
9 type Interface interface { | 13 type RawInterface interface { |
10 List() ([]string, error) | 14 List() ([]string, error) |
11 NumInstances(module, version string) (int, error) | 15 NumInstances(module, version string) (int, error) |
12 SetNumInstances(module, version string, instances int) error | 16 SetNumInstances(module, version string, instances int) error |
13 Versions(module string) ([]string, error) | 17 Versions(module string) ([]string, error) |
14 DefaultVersion(module string) (string, error) | 18 DefaultVersion(module string) (string, error) |
15 Start(module, version string) error | 19 Start(module, version string) error |
16 Stop(module, version string) error | 20 Stop(module, version string) error |
17 } | 21 } |
| 22 |
| 23 // List lists the names of modules belonging to this application. |
| 24 func List(c context.Context) ([]string, error) { |
| 25 return Raw(c).List() |
| 26 } |
| 27 |
| 28 // NumInstances returns the number of instances servicing the specified |
| 29 // module/version. |
| 30 // |
| 31 // If module or version is the empty string, it means the default. |
| 32 func NumInstances(c context.Context, module, version string) (int, error) { |
| 33 return Raw(c).NumInstances(module, version) |
| 34 } |
| 35 |
| 36 // SetNumInstances sets the number of instances of a given module/version. |
| 37 // |
| 38 // If module or version is the empty string, it means the default. |
| 39 func SetNumInstances(c context.Context, module, version string, instances int) e
rror { |
| 40 return Raw(c).SetNumInstances(module, version, instances) |
| 41 } |
| 42 |
| 43 // Versions returns the names of versions for the specified module. |
| 44 // |
| 45 // If module is the empty string, it means the default. |
| 46 func Versions(c context.Context, module string) ([]string, error) { |
| 47 return Raw(c).Versions(module) |
| 48 } |
| 49 |
| 50 // DefaultVersion returns the name of the default version for the specified |
| 51 // module. |
| 52 // |
| 53 // If module is the empty string, it means the default. |
| 54 func DefaultVersion(c context.Context, module string) (string, error) { |
| 55 return Raw(c).DefaultVersion(module) |
| 56 } |
| 57 |
| 58 // Start starts the specified module/version. |
| 59 // |
| 60 // If module or version is the empty string, it means the default. |
| 61 func Start(c context.Context, module, version string) error { |
| 62 return Raw(c).Start(module, version) |
| 63 } |
| 64 |
| 65 // Stop stops the specified module/version. |
| 66 // |
| 67 // If module or version is the empty string, it means the default. |
| 68 func Stop(c context.Context, module, version string) error { |
| 69 return Raw(c).Stop(module, version) |
| 70 } |
OLD | NEW |