本文整理匯總了Golang中github.com/tsuru/tsuru/app/bind.App.GetUnits方法的典型用法代碼示例。如果您正苦於以下問題:Golang App.GetUnits方法的具體用法?Golang App.GetUnits怎麽用?Golang App.GetUnits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/tsuru/app/bind.App
的用法示例。
在下文中一共展示了App.GetUnits方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UnbindApp
// UnbindApp makes the unbind between the service instance and an app.
func (si *ServiceInstance) UnbindApp(app bind.App, writer io.Writer) error {
err := si.RemoveApp(app.GetName())
if err != nil {
return &errors.HTTP{Code: http.StatusPreconditionFailed, Message: "This app is not bound to this service instance."}
}
err = si.update(nil)
if err != nil {
return err
}
var wg sync.WaitGroup
for _, unit := range app.GetUnits() {
wg.Add(1)
go func(unit bind.Unit) {
si.UnbindUnit(app, unit)
wg.Done()
}(unit)
}
instance := bind.ServiceInstance{Name: si.Name, Envs: make(map[string]string)}
for k, envVar := range app.InstanceEnv(si.Name) {
instance.Envs[k] = envVar.Value
}
wg.Wait()
if endpoint, err := si.Service().getClient("production"); err == nil {
endpoint.UnbindApp(si, app)
}
return app.RemoveInstance(si.ServiceName, instance, writer)
}
示例2: UnbindApp
// UnbindApp makes the unbind between the service instance and an app.
func (si *ServiceInstance) UnbindApp(app bind.App) error {
err := si.RemoveApp(app.GetName())
if err != nil {
return &errors.HTTP{Code: http.StatusPreconditionFailed, Message: "This app is not bound to this service instance."}
}
err = si.update()
if err != nil {
return err
}
for _, unit := range app.GetUnits() {
go func(unit bind.Unit) {
si.UnbindUnit(unit)
}(unit)
}
var envVars []string
for k := range app.InstanceEnv(si.Name) {
envVars = append(envVars, k)
}
return app.UnsetEnvs(envVars, false)
}