修改Add方法

This commit is contained in:
huangsimin 2019-11-07 11:15:56 +08:00
parent bd1bb4a03e
commit 30e531fe09

View File

@ -80,14 +80,20 @@ type Flow struct {
} }
// Add 添加 // Add 添加
func (flow *Flow) Add(node *FlowNode) { func (flow *Flow) Add(name string, task func(cxt *FlowContext) int) {
node := &FlowNode{Name: name}
if flow.Head == nil { if flow.Head == nil {
flow.Head = node flow.Head = node
flow.Tail = node flow.Tail = node
node.Path = node.Name
return return
} }
node.Path = flow.Tail.Path + ">" + flow.Tail.Name
flow.Tail.next = node flow.Tail.next = node
flow.Tail = node flow.Tail = node