本文整理匯總了Golang中github.com/concourse/atc.Worker.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang Worker.Name方法的具體用法?Golang Worker.Name怎麽用?Golang Worker.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/concourse/atc.Worker
的用法示例。
在下文中一共展示了Worker.Name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegisterWorker
func (s *Server) RegisterWorker(w http.ResponseWriter, r *http.Request) {
logger := s.logger.Session("register-worker")
var registration atc.Worker
err := json.NewDecoder(r.Body).Decode(®istration)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
if len(registration.GardenAddr) == 0 {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "missing address")
return
}
var ttl time.Duration
ttlStr := r.URL.Query().Get("ttl")
if len(ttlStr) > 0 {
ttl, err = time.ParseDuration(ttlStr)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "malformed ttl")
return
}
}
metric.WorkerContainers{
WorkerAddr: registration.GardenAddr,
Containers: registration.ActiveContainers,
}.Emit(s.logger)
if registration.Name == "" {
registration.Name = registration.GardenAddr
}
_, err = s.db.SaveWorker(db.WorkerInfo{
GardenAddr: registration.GardenAddr,
BaggageclaimURL: registration.BaggageclaimURL,
HTTPProxyURL: registration.HTTPProxyURL,
HTTPSProxyURL: registration.HTTPSProxyURL,
NoProxy: registration.NoProxy,
ActiveContainers: registration.ActiveContainers,
ResourceTypes: registration.ResourceTypes,
Platform: registration.Platform,
Tags: registration.Tags,
Name: registration.Name,
}, ttl)
if err != nil {
logger.Error("failed-to-save-worker", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}