go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/gae/service/module/interface.go (about) 1 // Copyright 2016 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package module 16 17 import ( 18 "context" 19 ) 20 21 // RawInterface is the interface for all of the package methods which normally 22 // would be in the 'module' package. 23 type RawInterface interface { 24 List() ([]string, error) 25 NumInstances(module, version string) (int, error) 26 SetNumInstances(module, version string, instances int) error 27 Versions(module string) ([]string, error) 28 DefaultVersion(module string) (string, error) 29 Start(module, version string) error 30 Stop(module, version string) error 31 } 32 33 // List lists the names of modules belonging to this application. 34 func List(c context.Context) ([]string, error) { 35 return Raw(c).List() 36 } 37 38 // NumInstances returns the number of instances servicing the specified 39 // module/version. 40 // 41 // If module or version is the empty string, it means the default. 42 func NumInstances(c context.Context, module, version string) (int, error) { 43 return Raw(c).NumInstances(module, version) 44 } 45 46 // SetNumInstances sets the number of instances of a given module/version. 47 // 48 // If module or version is the empty string, it means the default. 49 func SetNumInstances(c context.Context, module, version string, instances int) error { 50 return Raw(c).SetNumInstances(module, version, instances) 51 } 52 53 // Versions returns the names of versions for the specified module. 54 // 55 // If module is the empty string, it means the default. 56 func Versions(c context.Context, module string) ([]string, error) { 57 return Raw(c).Versions(module) 58 } 59 60 // DefaultVersion returns the name of the default version for the specified 61 // module. 62 // 63 // If module is the empty string, it means the default. 64 func DefaultVersion(c context.Context, module string) (string, error) { 65 return Raw(c).DefaultVersion(module) 66 } 67 68 // Start starts the specified module/version. 69 // 70 // If module or version is the empty string, it means the default. 71 func Start(c context.Context, module, version string) error { 72 return Raw(c).Start(module, version) 73 } 74 75 // Stop stops the specified module/version. 76 // 77 // If module or version is the empty string, it means the default. 78 func Stop(c context.Context, module, version string) error { 79 return Raw(c).Stop(module, version) 80 }