-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
196 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,57 @@ | ||
package flow | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
|
||
"github.com/goccy/go-graphviz" | ||
) | ||
|
||
func TestNewGraphviz(t *testing.T) { | ||
NewGraphviz() | ||
} | ||
} | ||
|
||
func Test_Parse_Graphviz(t *testing.T) { | ||
graph, err := graphviz.ParseBytes([]byte(DotTpl)) | ||
if err != nil { | ||
t.Errorf("ParseBytes err=%+v", err) | ||
} | ||
defer graph.Close() | ||
t.Log("graph: ", | ||
graph.Name(), | ||
graph.Get("label"), | ||
graph.Get("comment"), | ||
) | ||
t.Log("") | ||
|
||
node := graph.FirstNode() | ||
for node != nil { | ||
t.Log("next.Name()", | ||
node.Name(), | ||
node.Get("shape"), | ||
node.Get("label"), | ||
node.Get("comment"), | ||
) | ||
|
||
edge := graph.FirstEdge(node) | ||
for edge != nil { | ||
edgeNode := edge.Node() | ||
if edgeNode != nil { | ||
t.Log("edgeNode: ", | ||
edgeNode.Name(), | ||
edgeNode.Get("shape"), | ||
edgeNode.Get("label"), | ||
edgeNode.Get("comment"), | ||
) | ||
} | ||
t.Log("Edge: ", | ||
edge.Get("label"), | ||
edge.Get("comment"), | ||
) | ||
|
||
edge = graph.NextEdge(edge, edgeNode) | ||
} | ||
|
||
node = graph.NextNode(node) | ||
t.Log("") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package flow | ||
|
||
const ( | ||
DotTpl = `digraph en_name_audit { | ||
bgcolor="lightyellow" | ||
rankdir="LR" | ||
#布局第一列 | ||
{rank="same";} | ||
graph[label="测试dot" comment="{\"start_event\":\"event_start\",\"version\":\"v0.0.1\",\"no_strict\":true,\"remark\":\"测试dot备注\"}"] | ||
{ | ||
#事件 | ||
event_start [shape=circle label="开始" style=filled fillcolor=black fontcolor=green]; | ||
event_end_flow [shape=circle label="结束" style=filled fillcolor=black fontcolor=red]; | ||
#活动 | ||
activity_open_first [shape=box label="先发后审" style=filled fillcolor=gold]; | ||
activity_audit_first [shape=box label="先审后发" style=filled fillcolor=gold]; | ||
activity_pay_audit [shape=box label="付费审核" style=filled fillcolor=gold]; | ||
#网关 | ||
gateway_auto_distribution [shape=diamond label="自动分发网关" comment="{\"type\":\"xor\"}" style=filled fillcolor=pink]; | ||
gateway_pay_audit [shape=diamond label="付费审核网关" comment="{\"type\":\"xor\"}" style=filled fillcolor=pink]; | ||
} | ||
# 开始=>自动分发网关 | ||
event_start->gateway_auto_distribution; | ||
# 自动分发网关=>先发后审、先审后发、付费审核 | ||
gateway_auto_distribution->activity_pay_audit [label="命中付费审核" comment="{\"rule\":\"metadata.pay_season == 1\",\"sort\":3}"]; | ||
gateway_auto_distribution->activity_open_first [label="命中先发后审" comment="{\"rule\":\"extra6 == 1\",\"sort\":2}"]; | ||
gateway_auto_distribution->activity_audit_first [label="命中先审后发" comment="{\"rule\":\"extra6 != 1\",\"sort\":1}"]; | ||
# 付费审核=>付费审核网关 | ||
activity_pay_audit->gateway_pay_audit; | ||
# 付费审核网关=>先审后发、结束 | ||
gateway_pay_audit->activity_audit_first [label="命中先审后发" comment="{\"rule\":\"state == 0\",\"sort\":2}"]; | ||
gateway_pay_audit->event_end_flow [label="命中结束" comment="{\"rule\":\"state == -2 || state == -4\",\"sort\":1}"]; | ||
# 先发后审=>结束 | ||
activity_open_first->event_end_flow; | ||
# 先审后发=>结束 | ||
activity_audit_first->event_end_flow; | ||
}` | ||
) |
Oops, something went wrong.