feat(worker): implemented extra_status_manager option to enable a worker reporting status to multi

This commit is contained in:
bigeagle 2016-12-06 23:59:15 +08:00
parent 86153c59e3
commit a0b8ef08ab
2 changed files with 13 additions and 11 deletions

View File

@ -56,7 +56,8 @@ type globalConfig struct {
type managerConfig struct {
APIBase string `toml:"api_base"`
CACert string `toml:"ca_cert"`
Token string `toml:"token"`
ExtraStatusAPIs []string `toml:"extra_status_managers"`
// Token string `toml:"token"`
}
type serverConfig struct {

View File

@ -405,12 +405,6 @@ func (w *Worker) registorWorker() {
}
func (w *Worker) updateStatus(job *mirrorJob, jobMsg jobMessage) {
url := fmt.Sprintf(
"%s/workers/%s/jobs/%s",
w.cfg.Manager.APIBase,
w.Name(),
jobMsg.name,
)
p := job.provider
smsg := MirrorStatus{
Name: jobMsg.name,
@ -422,9 +416,16 @@ func (w *Worker) updateStatus(job *mirrorJob, jobMsg jobMessage) {
ErrorMsg: jobMsg.msg,
}
apiBases := []string{w.cfg.Manager.APIBase}
apiBases = append(apiBases, w.cfg.Manager.ExtraStatusAPIs...)
for _, root := range apiBases {
url := fmt.Sprintf(
"%s/workers/%s/jobs/%s", root, w.Name(), jobMsg.name,
)
if _, err := PostJSON(url, smsg, w.httpClient); err != nil {
logger.Errorf("Failed to update mirror(%s) status: %s", jobMsg.name, err.Error())
}
}
}
func (w *Worker) fetchJobStatus() []MirrorStatus {