本文整理匯總了Golang中github.com/flike/kingtask/task.TaskRequest.MaxRunTime方法的典型用法代碼示例。如果您正苦於以下問題:Golang TaskRequest.MaxRunTime方法的具體用法?Golang TaskRequest.MaxRunTime怎麽用?Golang TaskRequest.MaxRunTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/flike/kingtask/task.TaskRequest
的用法示例。
在下文中一共展示了TaskRequest.MaxRunTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateRpcTaskRequest
func (b *Broker) CreateRpcTaskRequest(c *echo.Context) error {
args := struct {
Method string `json:"method"`
URL string `json:"url"`
Args string `json:"args"` //json Marshal後的字符串
StartTime int64 `json:"start_time,string"`
TimeInterval string `json:"time_interval"` //空格分隔各個參數
MaxRunTime int64 `json:"max_run_time,string"`
}{}
err := c.Bind(&args)
if err != nil {
return c.JSON(http.StatusForbidden, err.Error())
}
fmt.Println(args)
taskRequest := new(task.TaskRequest)
taskRequest.Uuid = uuid.New()
if len(args.URL) == 0 {
return c.JSON(http.StatusForbidden, errors.ErrInvalidArgument.Error())
}
taskRequest.BinName = args.URL
taskRequest.Args = args.Args
taskRequest.StartTime = args.StartTime
taskRequest.TimeInterval = args.TimeInterval
taskRequest.Index = 0
taskRequest.MaxRunTime = args.MaxRunTime
switch args.Method {
case "GET":
taskRequest.TaskType = task.RpcTaskGET
case "POST":
taskRequest.TaskType = task.RpcTaskPOST
case "PUT":
taskRequest.TaskType = task.RpcTaskPUT
case "DELETE":
taskRequest.TaskType = task.RpcTaskDELETE
default:
return c.JSON(http.StatusForbidden, errors.ErrInvalidArgument.Error())
}
err = b.HandleRequest(taskRequest)
if err != nil {
return c.JSON(http.StatusForbidden, err.Error())
}
golog.Info("Broker", "CreateRpcTaskRequest", "ok", 0,
"uuid", taskRequest.Uuid,
"bin_name", taskRequest.BinName,
"args", taskRequest.Args,
"start_time", taskRequest.StartTime,
"time_interval", taskRequest.TimeInterval,
"index", taskRequest.Index,
"max_run_time", taskRequest.MaxRunTime,
"task_type", taskRequest.TaskType,
)
return c.JSON(http.StatusOK, taskRequest.Uuid)
}
示例2: CreateScriptTaskRequest
func (b *Broker) CreateScriptTaskRequest(c *echo.Context) error {
args := struct {
BinName string `json:"bin_name"`
Args string `json:"args"` //空格分隔各個參數
StartTime int64 `json:"start_time,string"`
TimeInterval string `json:"time_interval"` //空格分隔各個參數
MaxRunTime int64 `json:"max_run_time,string"`
}{}
err := c.Bind(&args)
if err != nil {
return c.JSON(http.StatusForbidden, err.Error())
}
taskRequest := new(task.TaskRequest)
taskRequest.Uuid = uuid.New()
if len(args.BinName) == 0 {
return c.JSON(http.StatusForbidden, errors.ErrInvalidArgument.Error())
}
taskRequest.BinName = args.BinName
taskRequest.Args = args.Args
taskRequest.StartTime = args.StartTime
taskRequest.TimeInterval = args.TimeInterval
taskRequest.Index = 0
taskRequest.MaxRunTime = args.MaxRunTime
taskRequest.TaskType = task.ScriptTask
err = b.HandleRequest(taskRequest)
if err != nil {
return c.JSON(http.StatusForbidden, err.Error())
}
golog.Info("Broker", "CreateScriptTaskRequest", "ok", 0,
"uuid", taskRequest.Uuid,
"bin_name", taskRequest.BinName,
"args", taskRequest.Args,
"start_time", taskRequest.StartTime,
"time_interval", taskRequest.TimeInterval,
"index", taskRequest.Index,
"max_run_time", taskRequest.MaxRunTime,
"task_type", taskRequest.TaskType,
)
return c.JSON(http.StatusOK, taskRequest.Uuid)
}