diff --git a/task.go b/task.go index 57eaf92..0ad65f3 100644 --- a/task.go +++ b/task.go @@ -1,6 +1,8 @@ package imitate import ( + "log" + "474420502.top/eson/curl2info" "474420502.top/eson/requests" ) @@ -59,6 +61,11 @@ func NewPerson(conf string) *Person { return person } +// Execute 人的执行所有任务 +func (person *Person) Execute() { + +} + // Task 任务 type Task struct { Curl *curl2info.CURL @@ -67,14 +74,6 @@ type Task struct { Proxies *CircularLinked } -// PlanResult 执行计划后返回的结果 -type PlanResult struct { - OK bool - Error error - CallBack string - Response *requests.Response -} - // NewTask 生成一个新任务 func NewTask(Curl *curl2info.CURL, Plans ...IExecute) *Task { @@ -94,27 +93,18 @@ func NewTask(Curl *curl2info.CURL, Plans ...IExecute) *Task { } // ExecuteOnPlan 按照计划执行任务并返回结果 -func (task *Task) ExecuteOnPlan() []*PlanResult { - var PRList []*PlanResult +func (task *Task) ExecuteOnPlan() { for _, exec := range task.Plan.GetLoopValues() { - pr := &PlanResult{Error: nil, OK: false} iexec := exec.GetValue().(IExecute) if iexec.TimeTo() >= 0 { - resp, err := task.Execute() - if err != nil { - pr.Error = err - } else { - pr.OK = true - pr.Response = resp - } iexec.CalculateTrigger() + task.Execute() } - PRList = append(PRList, pr) } - return PRList } -// Execute 根据curl信息执行, TODO: 超时设置 -func (task *Task) Execute() (*requests.Response, error) { - return task.Curl.CreateWorkflow(nil).Execute() +// Execute 根据curl信息执行, TODO: 通用方法设置, 多太实现 +func (task *Task) Execute() { + resp, err := task.Curl.CreateWorkflow(nil).Execute() + log.Println(resp, err) }