本文整理汇总了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)
}