Documentation ¶
Index ¶
- type Edge
- type EventGenerator
- func (g *EventGenerator) AddExitVertex(exit ...Vertex)
- func (g *EventGenerator) AddInitialEntryVertex(entry ...Vertex)
- func (g *EventGenerator) AddModel(model Model)
- func (g *EventGenerator) AddRandomEntryVertex(exit ...Vertex)
- func (g *EventGenerator) DeepCopy() Generator
- func (g *EventGenerator) GetNextVertices() []Vertex
- func (g *EventGenerator) GetVersion() int64
- func (g *EventGenerator) HasNextVertex() bool
- func (g EventGenerator) ListGeneratedVertices() []Vertex
- func (g *EventGenerator) Reset()
- func (g *EventGenerator) SetBatchGenerationRule(canDoBatchFunc func([]Vertex, []Vertex) bool)
- func (g *EventGenerator) SetVersion(version int64)
- type Generator
- type HistoryEventEdge
- func (c *HistoryEventEdge) DeepCopy() Edge
- func (c HistoryEventEdge) GetAction() func()
- func (c HistoryEventEdge) GetCondition() func(...interface{}) bool
- func (c HistoryEventEdge) GetEndVertex() Vertex
- func (c HistoryEventEdge) GetStartVertex() Vertex
- func (c *HistoryEventEdge) SetAction(action func())
- func (c *HistoryEventEdge) SetCondition(condition func(...interface{}) bool)
- func (c *HistoryEventEdge) SetEndVertex(end Vertex)
- func (c *HistoryEventEdge) SetStartVertex(start Vertex)
- type HistoryEventModel
- type HistoryEventVertex
- func (he HistoryEventVertex) DeepCopy() Vertex
- func (he *HistoryEventVertex) GenerateData(input ...interface{}) interface{}
- func (he HistoryEventVertex) GetData() interface{}
- func (he HistoryEventVertex) GetDataFunc() func(...interface{}) interface{}
- func (he HistoryEventVertex) GetMaxNextVertex() int
- func (he HistoryEventVertex) GetName() string
- func (he HistoryEventVertex) IsStrictOnNextVertex() bool
- func (he *HistoryEventVertex) SetDataFunc(dataFunc func(...interface{}) interface{})
- func (he *HistoryEventVertex) SetIsStrictOnNextVertex(isStrict bool)
- func (he *HistoryEventVertex) SetMaxNextVertex(maxNextGeneration int)
- func (he *HistoryEventVertex) SetName(name string)
- type Model
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Edge ¶
type 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(...interface{}) bool) GetCondition() func(...interface{}) bool // Action defines function to perform when the end vertex reached SetAction(func()) GetAction() func() DeepCopy() Edge }
Edge is the connection between two vertices
func NewHistoryEventEdge ¶
NewHistoryEventEdge initials a new edge between two HistoryEventVertexes
type EventGenerator ¶
type EventGenerator struct {
// contains filtered or unexported fields
}
EventGenerator is a history event generator The event generator will generate next history event based on the history event transition graph defined in the model
func (*EventGenerator) AddExitVertex ¶
func (g *EventGenerator) AddExitVertex( exit ...Vertex, )
AddExitVertex adds the terminate history event vertex
func (*EventGenerator) AddInitialEntryVertex ¶
func (g *EventGenerator) AddInitialEntryVertex( entry ...Vertex, )
AddInitialEntryVertex adds the initial history event vertices Generator will only start from one of the entry vertex
func (*EventGenerator) AddModel ¶
func (g *EventGenerator) AddModel( model Model, )
AddModel adds a history event model
func (*EventGenerator) AddRandomEntryVertex ¶
func (g *EventGenerator) AddRandomEntryVertex( exit ...Vertex, )
AddRandomEntryVertex adds the random history event vertex
func (*EventGenerator) DeepCopy ¶
func (g *EventGenerator) DeepCopy() Generator
DeepCopy copy a new instance of generator
func (*EventGenerator) GetNextVertices ¶
func (g *EventGenerator) GetNextVertices() []Vertex
GetNextVertices generates a batch of history events happened in the same transaction
func (*EventGenerator) GetVersion ¶
func (g *EventGenerator) GetVersion() int64
GetVersion returns event version
func (*EventGenerator) HasNextVertex ¶
func (g *EventGenerator) HasNextVertex() bool
HasNextVertex checks if there is accessible history event vertex
func (EventGenerator) ListGeneratedVertices ¶
func (g EventGenerator) ListGeneratedVertices() []Vertex
ListGeneratedVertices returns all the generated history events
func (*EventGenerator) Reset ¶
func (g *EventGenerator) Reset()
Reset reset the generator to the initial state
func (*EventGenerator) SetBatchGenerationRule ¶
func (g *EventGenerator) SetBatchGenerationRule( canDoBatchFunc func([]Vertex, []Vertex) bool, )
SetBatchGenerationRule sets a function to determine next generated batch of history events
func (*EventGenerator) SetVersion ¶
func (g *EventGenerator) SetVersion(version int64)
SetVersion sets the event version
type Generator ¶
type 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 }
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 }
func InitializeHistoryEventGenerator ¶
InitializeHistoryEventGenerator initializes the history event generator
func NewEventGenerator ¶
NewEventGenerator initials the event generator
type HistoryEventEdge ¶
type HistoryEventEdge struct {
// contains filtered or unexported fields
}
HistoryEventEdge is the directional edge of two history events
func (*HistoryEventEdge) DeepCopy ¶
func (c *HistoryEventEdge) DeepCopy() Edge
DeepCopy copies a new edge
func (HistoryEventEdge) GetAction ¶
func (c HistoryEventEdge) GetAction() func()
GetAction returns the action
func (HistoryEventEdge) GetCondition ¶
func (c HistoryEventEdge) GetCondition() func(...interface{}) bool
GetCondition returns the condition
func (HistoryEventEdge) GetEndVertex ¶
func (c HistoryEventEdge) GetEndVertex() Vertex
GetEndVertex returns the end vertex
func (HistoryEventEdge) GetStartVertex ¶
func (c HistoryEventEdge) GetStartVertex() Vertex
GetStartVertex returns the start vertex
func (*HistoryEventEdge) SetAction ¶
func (c *HistoryEventEdge) SetAction(action func())
SetAction sets an action to perform when the end vertex hits
func (*HistoryEventEdge) SetCondition ¶
func (c *HistoryEventEdge) SetCondition( condition func(...interface{}) bool, )
SetCondition sets the condition to access this edge
func (*HistoryEventEdge) SetEndVertex ¶
func (c *HistoryEventEdge) SetEndVertex(end Vertex)
SetEndVertex sets the end vertex
func (*HistoryEventEdge) SetStartVertex ¶
func (c *HistoryEventEdge) SetStartVertex( start Vertex, )
SetStartVertex sets the start vertex
type HistoryEventModel ¶
type HistoryEventModel struct {
// contains filtered or unexported fields
}
HistoryEventModel is a graph represents relationships among history event types
func (*HistoryEventModel) AddEdge ¶
func (m *HistoryEventModel) AddEdge( edge ...Edge, )
AddEdge adds an edge to the model
func (HistoryEventModel) ListEdges ¶
func (m HistoryEventModel) ListEdges() []Edge
ListEdges returns all added edges
type HistoryEventVertex ¶
type HistoryEventVertex struct {
// contains filtered or unexported fields
}
HistoryEventVertex represents one type of history event
func (HistoryEventVertex) DeepCopy ¶
func (he HistoryEventVertex) DeepCopy() Vertex
DeepCopy returns the a deep copy of vertex
func (*HistoryEventVertex) GenerateData ¶
func (he *HistoryEventVertex) GenerateData( input ...interface{}, ) interface{}
GenerateData generates the data and return
func (HistoryEventVertex) GetData ¶
func (he HistoryEventVertex) GetData() interface{}
GetData returns the vertex data
func (HistoryEventVertex) GetDataFunc ¶
func (he HistoryEventVertex) GetDataFunc() func(...interface{}) interface{}
GetDataFunc returns the data generation function
func (HistoryEventVertex) GetMaxNextVertex ¶
func (he HistoryEventVertex) GetMaxNextVertex() int
GetMaxNextVertex returns the max concurrent path
func (HistoryEventVertex) GetName ¶
func (he HistoryEventVertex) GetName() string
GetName returns the name
func (HistoryEventVertex) IsStrictOnNextVertex ¶
func (he HistoryEventVertex) IsStrictOnNextVertex() bool
IsStrictOnNextVertex returns the isStrict flag
func (*HistoryEventVertex) SetDataFunc ¶
func (he *HistoryEventVertex) SetDataFunc( dataFunc func(...interface{}) interface{}, )
SetDataFunc sets the data generation function
func (*HistoryEventVertex) SetIsStrictOnNextVertex ¶
func (he *HistoryEventVertex) SetIsStrictOnNextVertex( isStrict bool, )
SetIsStrictOnNextVertex sets if a vertex can be added between the current vertex and its child Vertices
func (*HistoryEventVertex) SetMaxNextVertex ¶
func (he *HistoryEventVertex) SetMaxNextVertex( maxNextGeneration int, )
SetMaxNextVertex sets the max concurrent path can be generated from this vertex
func (*HistoryEventVertex) SetName ¶
func (he *HistoryEventVertex) SetName( name string, )
SetName sets the name
type Model ¶
Model represents a state transition graph that contains all the relationships of Vertex
func NewHistoryEventModel ¶
func NewHistoryEventModel() Model
NewHistoryEventModel initials new history event model
type Vertex ¶
type Vertex interface { // The name of the vertex. Usually, this will be the Cadence 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(...interface{}) interface{}) GetDataFunc() func(...interface{}) interface{} GenerateData(...interface{}) interface{} GetData() interface{} DeepCopy() Vertex }
Vertex represents a state in the model. A state represents a type of an Cadence event
func NewHistoryEventVertex ¶
NewHistoryEventVertex initials a history event vertex