dag

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: LGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound       = errors.New("not found")
	ErrKeyIsExisted      = errors.New("already existed")
	ErrInvalidProtoToDag = errors.New("Protobuf message cannot be converted into Dag")
	ErrInvalidDagToProto = errors.New("Dag cannot be converted into Protobuf message")
)

Errors

View Source
var (
	ErrDagHasCirclular = errors.New("dag hava circlular")
	ErrTimeout         = errors.New("dispatcher execute timeout")
)

Errors

Functions

This section is empty.

Types

type Callback

type Callback func(*Node, interface{}) error

Callback func node

type Dag

type Dag struct {
	// contains filtered or unexported fields
}

Dag struct

func NewDag

func NewDag() *Dag

NewDag new dag

func (*Dag) AddEdge

func (dag *Dag) AddEdge(fromKey, toKey interface{}) error

AddEdge add edge fromKey toKey

func (*Dag) AddNode

func (dag *Dag) AddNode(key interface{}) error

AddNode add node

func (*Dag) FromProto

func (dag *Dag) FromProto(msg proto.Message) error

FromProto converts proto Dag to domain Dag

func (*Dag) GetChildrenNodes

func (dag *Dag) GetChildrenNodes(key interface{}) []*Node

GetChildrenNodes get children nodes with key

func (*Dag) GetNode

func (dag *Dag) GetNode(key interface{}) *Node

GetNode get node by key

func (*Dag) GetNodes

func (dag *Dag) GetNodes() []*Node

GetNodes get all nodes

func (*Dag) GetRootNodes

func (dag *Dag) GetRootNodes() []*Node

GetRootNodes get root nodes

func (*Dag) IsCirclular

func (dag *Dag) IsCirclular() bool

IsCirclular a->b-c->a

func (*Dag) Len

func (dag *Dag) Len() int

Len Dag len

func (*Dag) String

func (dag *Dag) String() string

String

func (*Dag) ToProto

func (dag *Dag) ToProto() (proto.Message, error)

ToProto converts domain Dag into proto Dag

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher struct a message dispatcher dag.

func NewDispatcher

func NewDispatcher(dag *Dag, concurrency int, elapseInMs int64, context interface{}, cb Callback) *Dispatcher

NewDispatcher create Dag Dispatcher instance.

func (*Dispatcher) Run

func (dp *Dispatcher) Run() error

Run dag dispatch goroutine.

func (*Dispatcher) Stop

func (dp *Dispatcher) Stop()

Stop stop goroutine.

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node struct

func NewNode

func NewNode(key interface{}, index int) *Node

NewNode new node

func (*Node) Index

func (n *Node) Index() int

Index return node index

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task struct

Directories

Path Synopsis
Package dagpb is a generated protocol buffer package.
Package dagpb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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