func DeleteServer(svcId, srvId string) error { // in case of failure srv, err := database.GetServer(svcId, srvId) if err != nil { if !strings.Contains(err.Error(), "No Server Found") { return err } } // delete rule from balancer if err = balance.DeleteServer(svcId, srvId); err != nil { if !strings.Contains(err.Error(), "No Server Found") { return err } } if !database.CentralStore { // remove from backend if err = database.DeleteServer(svcId, srvId); err != nil && !strings.Contains(err.Error(), "No Server Found") { // undo balance action if uerr := balance.SetServer(svcId, srv); uerr != nil { err = fmt.Errorf("%v - %v", err.Error(), uerr.Error()) } return err } } return nil }
func TestGetServer(t *testing.T) { server, err := database.GetServer(testService1.Id, testServer2.Id) if err != nil { t.Errorf("Failed to GET server - %v", err) } if server.Id != testServer2.Id { t.Errorf("Read server differs from written server") } }
func GetServer(svcId, srvId string) (*core.Server, error) { return database.GetServer(svcId, srvId) }