func launch(storeAddr, projectID, service string) error { // Store, project and router st := &etcd.Etcd{} st.New(storeAddr) project, err := controller.GetProject(projectID, st) if err != nil { return err } routerAddr, err := project.Store.Read("addr", "router") if err != nil { return err } // Client client, err := wrapper.ConnectWamp(routerAddr, "realm1") if err != nil { return err } // Wrapper w := wrapper.New(service, project, client) dir := fmt.Sprintf("services/%s", service) w.Cmd, err = project.Store.Read("command", dir) if err != nil { return err } log.Debugln("Cmd:", w.Cmd) w.Mode, err = project.Store.Read("input_mode", dir) if err != nil { return err } if err = w.Init(); err != nil { return err } uri := fmt.Sprintf("com.%s.%s", project.ID, service) rp := client.Register(uri, w.Procedure) <-rp.Registred client.End() return nil }
func launch(storeAddr, projectID, addr string) error { // Store, project and router st := &etcd.Etcd{} st.New(storeAddr) project, err := controller.GetProject(projectID, st) if err != nil { return err } routerAddr, err := project.Store.Read("addr", "router") if err != nil { return err } // Private client private, err := wrapper.ConnectWamp(routerAddr, "realm1") if err != nil { return err } // Wrapper w := wrapper.New("api", project, private) if err = w.Init(); err != nil { return err } // Handler and router h := NewHandler(w) router := httprouter.New() router.POST("/", h.httpAPI) router.GET("/jobs/:id/", h.httpJob) // Server log.Infoln("Serving API on:", addr) return http.ListenAndServe(addr, router) }