dag

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Use: 1. 调用方实现 dag.NamedNode 接口 2. 使用 dag.New(node1, node2, ...) 创建 DAG 3. 请看测试用例

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAG

type DAG struct {
	// Nodes represents map of name to Node in DAG.
	Nodes map[string]*defaultNode
	// contains filtered or unexported fields
}

DAG 代表 有向无环图.

func New

func New(nodes []NamedNode, ops ...Option) (*DAG, error)

New 返回一个 DAG @nodes: map[节点名]NamedNode

func (*DAG) GetSchedulable

func (g *DAG) GetSchedulable(finishes ...string) (map[string]Node, error)

GetSchedulable 根据 已完成的节点名 返回可执行的 节点 ([]Node).

func (*DAG) GetSchedulableNodeNames

func (g *DAG) GetSchedulableNodeNames(finishes ...string) ([]string, error)

GetSchedulableNodeNames 根据 已完成的节点名 返回可调度的 节点名 ([]string).

type NamedNode

type NamedNode interface {
	// NodeName 需要唯一标识一个节点
	NodeName() string
	// PrevNodeNames 表示与当前节点直接相连的前置节点
	PrevNodeNames() []string
}

NamedNode 方便用户使用,仅在创建 DAG 时使用

type Node

type Node interface {
	NamedNode
	PrevNodes() []Node
	NextNodes() []Node
	NextNodeNames() []string
}

Node 代表 DAG 的节点

type Option

type Option func(*DAG)

func WithAllowMarkArbitraryNodesAsDone

func WithAllowMarkArbitraryNodesAsDone(allow bool) Option

func WithAllowNotCheckCycle

func WithAllowNotCheckCycle(allow bool) Option

Jump to

Keyboard shortcuts

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