本文整理匯總了Golang中github.com/tsuru/tsuru/service.ServiceInstance.UnbindUnit方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceInstance.UnbindUnit方法的具體用法?Golang ServiceInstance.UnbindUnit怎麽用?Golang ServiceInstance.UnbindUnit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/tsuru/service.ServiceInstance
的用法示例。
在下文中一共展示了ServiceInstance.UnbindUnit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestUnbindUnit
func (s *S) TestUnbindUnit(c *gocheck.C) {
called := false
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
called = true
w.WriteHeader(http.StatusNoContent)
}))
defer ts.Close()
srvc := service.Service{Name: "mysql", Endpoint: map[string]string{"production": ts.URL}}
err := srvc.Create()
c.Assert(err, gocheck.IsNil)
defer s.conn.Services().Remove(bson.M{"_id": "mysql"})
instance := service.ServiceInstance{
Name: "my-mysql",
ServiceName: "mysql",
Teams: []string{s.team.Name},
Apps: []string{"painkiller"},
}
instance.Create()
defer s.conn.ServiceInstances().Remove(bson.M{"name": "my-mysql"})
a, err := createTestApp(s.conn, "painkiller", "", []string{s.team.Name})
c.Assert(err, gocheck.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
app.Provisioner.Provision(&a)
defer app.Provisioner.Destroy(&a)
err = instance.UnbindUnit(a.GetUnits()[0])
c.Assert(err, gocheck.IsNil)
c.Assert(called, gocheck.Equals, true)
}
示例2: BindUnit
func (app *App) BindUnit(unit *provision.Unit) error {
instances, err := app.serviceInstances()
if err != nil {
return err
}
var i int
var instance service.ServiceInstance
for i, instance = range instances {
err = instance.BindUnit(app, unit)
if err != nil {
log.Errorf("Error binding the unit %s with the service instance %s: %s", unit.ID, instance.Name, err)
break
}
}
if err != nil {
for j := i - 1; j >= 0; j-- {
instance = instances[j]
rollbackErr := instance.UnbindUnit(app, unit)
if rollbackErr != nil {
log.Errorf("Error unbinding unit %s with the service instance %s during rollback: %s", unit.ID, instance.Name, rollbackErr)
}
}
}
return err
}