当前位置: 首页>>代码示例>>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;未经允许,请勿转载。