planner

package
v0.0.0-...-9e9d5e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph struct {
	Nodes map[string]*Node
	Edges map[string][]string

	sync.RWMutex
}

Graph represents the graph data structure

func NewGraph

func NewGraph() *Graph

NewGraph creates a new instance of the graph and returns a pointer to it

func (*Graph) AddEdge

func (g *Graph) AddEdge(src, dest string) *Graph

AddEdge adds edge from source to destination nodes

These edges are unidirectional, hence for bidirectional edges this method needs to be called twice

func (*Graph) AddNode

func (g *Graph) AddNode(name string, data core.Service) *Graph

AddNode adds a node to the graph

func (*Graph) DetectCycle

func (g *Graph) DetectCycle() bool

DetectCycle will return true if there is a cycle in the graph

func (*Graph) Order

func (g *Graph) Order() int

Order returns the count for number of edges

func (*Graph) Traverse

func (g *Graph) Traverse(fn VisitFn)

Traverse traverses the graph in topological sorted order and executes the visit function on each visited node

func (*Graph) Visit

func (g *Graph) Visit(fn VisitFn)

Visit visits each node in the graph but does not keep track of the pre-visited nodes

type Node

type Node struct {
	Data core.Service
}

Node is a graph node

type ParallelProcessGraph

type ParallelProcessGraph struct {
	Edges map[string][]string

	ParallelProcessGraphNodeMap map[string]*ParallelProcessGraphNode
	// contains filtered or unexported fields
}

ParallelProcessGraph provides methods for parallel processing of the graph

func NewParallelProcessGraph

func NewParallelProcessGraph(g *Graph) *ParallelProcessGraph

NewParallelProcessGraph creates a parallel processing graph from a simple graph returns a pointer to ParallelProcessGraph

func (*ParallelProcessGraph) Traverse

func (g *ParallelProcessGraph) Traverse(fn VisitFn)

Traverse spins up the processes concurrently if it can

type ParallelProcessGraphNode

type ParallelProcessGraphNode struct {
	Name string
	Data *Node

	DepUpdateCh chan struct{}
	DepCancleCh chan struct{}

	DepCount int
	// contains filtered or unexported fields
}

ParallelProcessGraphNode is the node for ParallelProcessGraph it contains the constructs for channel based communication

func (*ParallelProcessGraphNode) Process

Process starts an internal loop which listens for the signals on the channels and operate accordingly

type Plan

type Plan struct {
	Data core.Pattern
	*Graph
}

Plan struct represents a node of an execution plan

func CreatePlan

func CreatePlan(pattern core.Pattern, invert bool) (*Plan, error)

CreatePlan takes in the application components and creates a plan of execution for it

func (*Plan) Execute

func (p *Plan) Execute(cb func(string, core.Service) bool) error

Execute traverses the plan and calls the callback function on each of the node

func (*Plan) IsFeasible

func (p *Plan) IsFeasible() bool

IsFeasible returns true if the plan execution is feasible

type Queue

type Queue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Queue is the thread safe queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() string

Dequeue removes data from the queue

func (*Queue) Enqueue

func (q *Queue) Enqueue(str string)

Enqueue data to the queue

func (*Queue) Length

func (q *Queue) Length() int

Length returns the length of the queue

func (*Queue) Peek

func (q *Queue) Peek() string

Peek returns the first item in the queue

type VisitFn

type VisitFn func(name string, node core.Service) bool

VisitFn is the function definition for the visitor function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL