Example #1
0
func handleWorkers(workerManager *client.WorkerManager, w http.ResponseWriter, r *http.Request) {
	workerStates := workerManager.ListWorkers()
	w.Header().Set("Content-Type", "application/json")
	if err := json.NewEncoder(w).Encode(workerStates); err != nil {
		panic(err)
	}
}
Example #2
0
func handleRegisterWorker(workerManager *client.WorkerManager, w http.ResponseWriter, r *http.Request) {
	info := client.WorkerInfo{
		Id:      r.FormValue("id"),
		Article: bitwrk.ArticleId(r.FormValue("article")),
		Method:  "http-push",
		PushURL: r.FormValue("pushurl"),
	}

	if r.Method != "POST" || info.Id == "" || info.PushURL == "" {
		registerWorkerTemplate.Execute(w, info)
	}

	workerManager.RegisterWorker(info)
}
Example #3
0
func handleUnregisterWorker(workerManager *client.WorkerManager, w http.ResponseWriter, r *http.Request) {
	workerManager.UnregisterWorker(r.FormValue("id"))
}