mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(cloudcommon): set TaskNotifyUrl in GetTaskRequestHeader
To support cross-service task callbacks, you must set TaskNotifyUrl, which is automatically added to TaskRequestHeader here
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
@@ -826,9 +827,19 @@ func (task *STask) GetTaskRequestHeader() http.Header {
|
||||
}
|
||||
header := mcclient.GetTokenHeaders(userCred)
|
||||
header.Set(mcclient.TASK_ID, task.GetTaskId())
|
||||
if len(serviceUrl) > 0 {
|
||||
notifyUrl := filepath.Join(serviceUrl, "tasks", task.GetTaskId())
|
||||
header.Set(mcclient.TASK_NOTIFY_URL, notifyUrl)
|
||||
}
|
||||
return header
|
||||
}
|
||||
|
||||
var serviceUrl string
|
||||
|
||||
func SetServiceUrl(url string) {
|
||||
serviceUrl = url
|
||||
}
|
||||
|
||||
func (task *STask) GetStartTime() time.Time {
|
||||
return task.CreatedAt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user