當前位置: 首頁>>代碼示例>>Golang>>正文


Golang backend.Cocaine類代碼示例

本文整理匯總了Golang中github.com/cocaine/cocaine-flow/backend.Cocaine的典型用法代碼示例。如果您正苦於以下問題:Golang Cocaine類的具體用法?Golang Cocaine怎麽用?Golang Cocaine使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Cocaine類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ApplicationStart

func ApplicationStart(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	name := r.FormValue("name")
	profile := r.FormValue("profile")

	if len(name) == 0 || len(profile) == 0 {
		http.Error(w, "name or profile wasn't specified", http.StatusInternalServerError)
		return
	}

	stream, err := cocs.ApplicationStart(name, profile)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	if f, ok := w.(http.Flusher); !ok {
		for {
			var p []byte
			_, err := stream.Read(p)
			fmt.Println(p, err)
			if err != nil {
				break
			}
			w.Write(p)
			f.Flush()
		}
	} else {
		body, _ := ioutil.ReadAll(stream)
		fmt.Fprintf(w, "%s", body)
	}
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:31,代碼來源:server.go

示例2: ApplicationUpload

func ApplicationUpload(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	name := mux.Vars(r)["name"]
	version := mux.Vars(r)["version"]

	defer r.Body.Close()
	path, err := archive.Unpack(r.Body)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	defer os.RemoveAll(path)

	info := backend.AppUplodaInfo{
		Path:    path,
		App:     name,
		Version: version,
	}

	ch, _, err := cocs.ApplicationUpload(info)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	for lg := range ch {
		w.Write([]byte(lg))
		w.(http.Flusher).Flush()
	}
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:29,代碼來源:server.go

示例3: HostList

func HostList(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	hosts, err := cocs.HostList()
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	SendJson(w, hosts)
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:9,代碼來源:server.go

示例4: ApplicationList

func ApplicationList(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	apps, err := cocs.ApplicationList()
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	SendJson(w, apps)
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:9,代碼來源:server.go

示例5: BuildLogList

func BuildLogList(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	buildlogs, err := cocs.BuildLogList()
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	SendJson(w, buildlogs)
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:9,代碼來源:server.go

示例6: GroupRemove

func GroupRemove(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	name := mux.Vars(r)["name"]
	err := cocs.GroupRemove(name)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	fmt.Fprint(w, "OK")
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:9,代碼來源:server.go

示例7: GroupRead

func GroupRead(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	name := mux.Vars(r)["name"]
	group, err := cocs.GroupRead(name)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	SendJson(w, group)
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:9,代碼來源:server.go

示例8: HostAdd

func HostAdd(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	host := mux.Vars(r)["host"]
	err := cocs.HostAdd(host)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	fmt.Fprint(w, "OK")
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:10,代碼來源:server.go

示例9: CrashlogList

func CrashlogList(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	name := mux.Vars(r)["name"]

	crashlogs, err := cocs.CrashlogList(name)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	SendJson(w, crashlogs)
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:10,代碼來源:server.go

示例10: ProfileList

func ProfileList(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	profiles, err := cocs.ProfileList()

	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	SendJson(w, profiles)
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:10,代碼來源:server.go

示例11: BuildLogRead

func BuildLogRead(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	id := mux.Vars(r)["id"]

	buildlog, err := cocs.BuildLogRead(id)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	fmt.Fprintf(w, buildlog)
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:11,代碼來源:server.go

示例12: GroupPopApp

func GroupPopApp(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	name := vars["name"]
	app := vars["app"]

	err := cocs.GroupPopApp(name, app)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	fmt.Fprint(w, "OK")
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:12,代碼來源:server.go

示例13: ProfileUpload

func ProfileUpload(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	name := mux.Vars(r)["name"]
	defer r.Body.Close()
	body, _ := ioutil.ReadAll(r.Body)
	if len(body) == 0 {
		http.Error(w, "Empty profile", http.StatusInternalServerError)
		return
	}

	err := cocs.ProfileUpload(name, body)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	fmt.Fprintln(w, "OK")
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:16,代碼來源:server.go

示例14: CrashlogView

func CrashlogView(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	name := vars["name"]
	timestamp, err := strconv.Atoi(vars["timestamp"])
	if err != nil {
		http.Error(w, "timestamp must be a number", http.StatusBadRequest)
		return
	}

	crashlog, err := cocs.CrashlogView(name, timestamp)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	fmt.Fprintf(w, crashlog)
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:16,代碼來源:server.go

示例15: GroupPushApp

func GroupPushApp(cocs backend.Cocaine, w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)

	name := vars["name"]
	app := vars["app"]
	weights, ok := r.URL.Query()["weight"]
	if !ok || len(weights) == 0 {
		http.Error(w, "weight argument is absent", http.StatusBadRequest)
		return
	}

	weight, err := strconv.Atoi(weights[0])
	if err != nil {
		http.Error(w, "weight must be an integer value", http.StatusBadRequest)
		return
	}

	err = cocs.GroupPushApp(name, app, weight)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	fmt.Fprint(w, "OK")
}
開發者ID:cocaine,項目名稱:cocaine-flow,代碼行數:24,代碼來源:server.go


注:本文中的github.com/cocaine/cocaine-flow/backend.Cocaine類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。