func handleMarathonEvent(req *http.Request) { event, err := decodeMarathonEvent(req) if err != nil { log.Errorf("Error decoding data callback: %v", err) return } if err = handleEvent(event); err != nil { log.Errorf("%v", err) } }
func removeVulcandServer(appID string, server VulcandServer) error { backend, err := fetchBackend(appID) if err != nil { log.Errorf("Error fetching backend from etcd: %v", err) return err } path := serverPath(backend, server.ID) err = etcdDelete(path) if err != nil { log.Errorf("Error delete key from etcd: %v", err) return err } log.Infof("Removed server: %s from backend: %s, url: %s", server.ID, backend.BackendID, server.URL) return nil }
func fetchBackend(appID string) (*BackendConfig, error) { value, err := etcdGet(appPath(appID)) if err != nil { log.Errorf("Error fetching backend from etcd: %v", err) return nil, err } backend := BackendConfig{} err = json.Unmarshal(value, &backend) return &backend, err }
func addVulcandServer(appID string, server VulcandServer) error { backend, err := fetchBackend(appID) if err != nil { return err } path := serverPath(backend, server.ID) value := backend.Format(server) err = etcdSet(path, value) if err != nil { log.Errorf("Error setting key in etcd: %v", err) return err } log.Infof("Added server: %s to backend: %s, url: %s", server.ID, backend.BackendID, server.URL) return nil }
func die(err error) { log.Errorf("%v", err) os.Exit(1) }