本文整理汇总了Golang中github.com/tsuru/tsuru/router.Remove函数的典型用法代码示例。如果您正苦于以下问题:Golang Remove函数的具体用法?Golang Remove怎么用?Golang Remove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Remove函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: RemoveBackend
func (r elbRouter) RemoveBackend(name string) error {
backendName, err := router.Retrieve(name)
if err != nil {
return err
}
_, err = r.elb().DeleteLoadBalancer(backendName)
if err != nil {
return err
}
return router.Remove(backendName)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:11,代码来源:router.go
示例2: RemoveBackend
func (r *fakeRouter) RemoveBackend(name string) error {
backendName, err := router.Retrieve(name)
if err != nil {
return err
}
if !r.HasBackend(backendName) {
return router.ErrBackendNotFound
}
r.mutex.Lock()
defer r.mutex.Unlock()
delete(r.backends, backendName)
return router.Remove(backendName)
}
开发者ID:RichardKnop,项目名称:tsuru,代码行数:13,代码来源:router.go
示例3: RemoveBackend
func (r *vulcandRouter) RemoveBackend(name string) error {
usedName, err := router.Retrieve(name)
if err != nil {
return err
}
if usedName != name {
return router.ErrBackendSwapped
}
backendKey := engine.BackendKey{Id: r.backendName(usedName)}
frontends, err := r.client.GetFrontends()
if err != nil {
return &router.RouterError{Err: err, Op: "remove-backend"}
}
toRemove := []engine.FrontendKey{}
for _, f := range frontends {
if f.BackendId == backendKey.Id {
toRemove = append(toRemove, engine.FrontendKey{Id: f.GetId()})
}
}
for _, fk := range toRemove {
err := r.client.DeleteFrontend(fk)
if err != nil {
if _, ok := err.(*engine.NotFoundError); ok {
return router.ErrBackendNotFound
}
return &router.RouterError{Err: err, Op: "remove-backend"}
}
}
routes, err := r.Routes(name)
if err != nil {
return err
}
for _, route := range routes {
err = r.RemoveRoute(name, route)
if err != nil {
return err
}
}
err = r.client.DeleteBackend(backendKey)
if err != nil {
if _, ok := err.(*engine.NotFoundError); ok {
return router.ErrBackendNotFound
}
return &router.RouterError{Err: err, Op: "remove-backend"}
}
return router.Remove(usedName)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:47,代码来源:router.go
示例4: RemoveBackend
func (r *hipacheRouter) RemoveBackend(name string) error {
backendName, err := router.Retrieve(name)
if err != nil {
return err
}
if backendName != name {
return router.ErrBackendSwapped
}
domain, err := config.GetString(r.prefix + ":domain")
if err != nil {
return &router.RouterError{Op: "remove", Err: err}
}
frontend := "frontend:" + backendName + "." + domain
conn, err := r.connect()
if err != nil {
return &router.RouterError{Op: "remove", Err: err}
}
err = conn.Del(frontend).Err()
if err != nil {
return &router.RouterError{Op: "remove", Err: err}
}
err = router.Remove(backendName)
if err != nil {
return &router.RouterError{Op: "remove", Err: err}
}
cnames, err := r.getCNames(backendName)
if err != nil {
return err
}
if cnames == nil {
return nil
}
for _, cname := range cnames {
err = conn.Del("frontend:" + cname).Err()
if err != nil {
return &router.RouterError{Op: "remove", Err: err}
}
}
err = conn.Del("cname:" + backendName).Err()
if err != nil {
return &router.RouterError{Op: "remove", Err: err}
}
return nil
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:44,代码来源:router.go
示例5: RemoveBackend
func (r *fakeRouter) RemoveBackend(name string) error {
backendName, err := router.Retrieve(name)
if err != nil {
return err
}
if backendName != name {
return router.ErrBackendSwapped
}
if !r.HasBackend(backendName) {
return router.ErrBackendNotFound
}
r.mutex.Lock()
defer r.mutex.Unlock()
for cname, backend := range r.cnames {
if backend == backendName {
delete(r.cnames, cname)
}
}
delete(r.backends, backendName)
return router.Remove(backendName)
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:21,代码来源:router.go
示例6: Delete
// Delete deletes an app.
func Delete(app *App, w io.Writer) error {
isSwapped, swappedWith, err := router.IsSwapped(app.GetName())
if err != nil {
return errors.Wrap(err, "unable to check if app is swapped")
}
if isSwapped {
return errors.Errorf("application is swapped with %q, cannot remove it", swappedWith)
}
appName := app.Name
if w == nil {
w = ioutil.Discard
}
fmt.Fprintf(w, "---- Removing application %q...\n", appName)
var hasErrors bool
defer func() {
var problems string
if hasErrors {
problems = " Some errors occurred during removal."
}
fmt.Fprintf(w, "---- Done removing application.%s\n", problems)
}()
logErr := func(msg string, err error) {
msg = fmt.Sprintf("%s: %s", msg, err)
fmt.Fprintf(w, "%s\n", msg)
log.Errorf("[delete-app: %s] %s", appName, msg)
hasErrors = true
}
prov, err := app.getProvisioner()
if err != nil {
return err
}
err = prov.Destroy(app)
if err != nil {
logErr("Unable to destroy app in provisioner", err)
}
r, err := app.Router()
if err == nil {
err = r.RemoveBackend(app.Name)
}
if err != nil {
logErr("Failed to remove router backend", err)
}
err = router.Remove(app.Name)
if err != nil {
logErr("Failed to remove router backend from database", err)
}
err = app.unbind()
if err != nil {
logErr("Unable to unbind app", err)
}
err = repository.Manager().RemoveRepository(appName)
if err != nil {
logErr("Unable to remove app from repository manager", err)
}
token := app.Env["TSURU_APP_TOKEN"].Value
err = AuthScheme.AppLogout(token)
if err != nil {
logErr("Unable to remove app token in destroy", err)
}
owner, err := auth.GetUserByEmail(app.Owner)
if err == nil {
err = auth.ReleaseApp(owner)
}
if err != nil {
logErr("Unable to release app quota", err)
}
logConn, err := db.LogConn()
if err == nil {
defer logConn.Close()
err = logConn.Logs(appName).DropCollection()
}
if err != nil {
logErr("Unable to remove logs collection", err)
}
conn, err := db.Conn()
if err == nil {
defer conn.Close()
err = conn.Apps().Remove(bson.M{"name": appName})
}
if err != nil {
logErr("Unable to remove app from db", err)
}
err = event.MarkAsRemoved(event.Target{Type: event.TargetTypeApp, Value: appName})
if err != nil {
logErr("Unable to mark old events as removed", err)
}
return nil
}
开发者ID:tsuru,项目名称:tsuru,代码行数:89,代码来源:app.go
注:本文中的github.com/tsuru/tsuru/router.Remove函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论