TODO: execute plan

This commit is contained in:
huangsimin 2018-11-26 18:53:37 +08:00
parent 34c1468578
commit 121cf7c67d
3 changed files with 41 additions and 34 deletions

View File

@ -1,9 +1,5 @@
package imitate
import (
"github.com/474420502/requests"
)
// type ExecuteRecord struct {
// IsSuccess bool
// FailCount int
@ -24,34 +20,32 @@ type IExecute interface {
}
// ExecutePlan 执行时间的计划表
type ExecutePlan struct {
ExecuteQueue []IExecute
}
type ExecutePlan CircularLinked
// PlanResult 执行计划表的结果
type PlanResult struct {
Exec IExecute
Resp *requests.Response
}
// // PlanResult 执行计划表的结果
// type PlanResult struct {
// Exec IExecute
// Resp *requests.Response
// }
// NewExecutePlan create a plan
func NewExecutePlan() *ExecutePlan {
plan := &ExecutePlan{}
// // NewExecutePlan create a plan
// func NewExecutePlan() *ExecutePlan {
// plan := &ExecutePlan{}
// plan.ExecuteQueue = NewCircularLinked()
// return plan
// }
return plan
}
// // AppendIExecute 添加执行计划任务
// func (ep *ExecutePlan) AppendIExecute(e IExecute) {
// ep.ExecuteQueue.Append(e)
// }
// AppendIExecute 添加执行计划任务
func (ep *ExecutePlan) AppendIExecute(e IExecute) {
ep.ExecuteQueue = append(ep.ExecuteQueue, e)
}
// // ClearIExecute 清除执行计划任务
// func (ep *ExecutePlan) ClearIExecute() {
// ep.ExecuteQueue = NewCircularLinked()
// }
// ClearIExecute 清除执行计划任务
func (ep *ExecutePlan) ClearIExecute() {
ep.ExecuteQueue = []IExecute{}
}
// CountIExecute 清除执行计划任务
func (ep *ExecutePlan) CountIExecute() int {
return len(ep.ExecuteQueue)
}
// // CountIExecute 清除执行计划任务
// func (ep *ExecutePlan) CountIExecute() uint64 {
// return ep.ExecuteQueue.Size()
// }

View File

@ -12,19 +12,23 @@ import (
type Person struct {
Tasks []Task
Conf *Config
}
type Task struct {
Curl *curl2info.CURL
Conf *Config
Plan *ExecutePlan
}
func NewTask(conf string, curlinfo string) *Task {
task := &Task{}
func NewPerson(conf string, curlinfo string) *Person {
return nil
}
task.Conf = NewConfig(conf)
func NewTask(curlinfo string, Plan *ExecutePlan) *Task {
task := &Task{}
// task.Conf = NewConfig(conf)
task.Curl = curl2info.NewCURL(curlinfo)
task.Plan = Plan
return task
}

View File

@ -191,6 +191,15 @@ func (list *CircularLinked) Size() uint64 {
return list.size
}
// Clone 复制一个完整的链表, 只是value引用, 如果是指针他们(链表)之间, 操作value会可能产生影响
func (list *CircularLinked) Clone() *CircularLinked {
cl := NewCircularLinked()
for i := uint64(0); i < list.size; i++ {
cl.Append(list.cursor.value)
}
return cl
}
func (list *CircularLinked) errorNotInList(node *Node) {
log.Println("the node value ", spew.Sprint(node), " is not in list")
}