-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathgenerator_interface.go
More file actions
83 lines (78 loc) · 2.92 KB
/
generator_interface.go
File metadata and controls
83 lines (78 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package testing
type (
// Model represents a state transition graph that contains all the relationships of Vertex
Model interface {
AddEdge(...Edge)
ListEdges() []Edge
}
// Generator generates a sequence of vertices based on the defined models
// It must define InitialEntryVertex and ExitVertex
// To use a generator:
// for generator.HasNextVertex {
// generator.GetNextVertices
// }
Generator interface {
// InitialEntryVertex is the beginning vertices of the graph
// Only one vertex will be picked as the entry
AddInitialEntryVertex(...Vertex)
// ExitVertex is the terminate vertices of the graph
AddExitVertex(...Vertex)
// RandomEntryVertex is a random entry point which can be access at any state of the generator
AddRandomEntryVertex(...Vertex)
// AddModel loads model into the generator
// AddModel can load multiple models and models will be joint if there is common vertices
AddModel(Model)
// HasNextVertex determines if there is more vertex to generate
HasNextVertex() bool
// GetNextVertices generates next vertex batch
GetNextVertices() []Vertex
// ListGeneratedVertices lists the pasted generated vertices
ListGeneratedVertices() []Vertex
// Reset cleans up all the internal states and reset to a brand new generator
Reset()
// DeepCopy copy a new instance of generator
DeepCopy() Generator
// SetBatchGenerationRule sets a function that used in GetNextVertex to return batch result
SetBatchGenerationRule(func([]Vertex, []Vertex) bool)
// SetVersion sets the event version
SetVersion(int64)
// GetVersion gets the event version
GetVersion() int64
}
// Vertex represents a state in the model. A state represents a type of an Temporal event
Vertex interface {
// The name of the vertex. Usually, this will be the Temporal event type
SetName(string)
GetName() string
// Equals(Vertex) bool
// IsStrictOnNextVertex means if the vertex must be followed by its children
// When IsStrictOnNextVertex set to true, it means this event can only follow by its neighbors
SetIsStrictOnNextVertex(bool)
IsStrictOnNextVertex() bool
// MaxNextVertex means the max neighbors can branch out from this vertex
SetMaxNextVertex(int)
GetMaxNextVertex() int
// SetVertexDataFunc sets a function to generate end vertex data
SetDataFunc(func(...any) any)
GetDataFunc() func(...any) any
GenerateData(...any) any
GetData() any
DeepCopy() Vertex
}
// Edge is the connection between two vertices
Edge interface {
// StartVertex is the head of the connection
SetStartVertex(Vertex)
GetStartVertex() Vertex
// EndVertex is the end of the connection
SetEndVertex(Vertex)
GetEndVertex() Vertex
// Condition defines a function to determine if this connection is accessible
SetCondition(func(...any) bool)
GetCondition() func(...any) bool
// Action defines function to perform when the end vertex reached
SetAction(func())
GetAction() func()
DeepCopy() Edge
}
)