本文整理匯總了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)
}
示例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)
}
示例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)
}
示例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
}
示例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)
}
示例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
}