internal

package
v0.0.0-...-0dd650e Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusTodo = iota
	StatusDoing
	StatusDone
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph[E any] struct {
	Vertices map[string]*GraphVertex[E]
	Edges    map[GraphEdge[E]]bool

	Heads        []*GraphVertex[E]
	SerialGroups map[string][]*GraphVertex[E]
	DoingMap     map[string]struct{}
	ScheduleNum  int

	sync.Mutex
}

func MapToNewGraph

func MapToNewGraph[OE any, NE any](graph *Graph[OE], mapper Mapper[OE, NE]) (*Graph[NE], error)

func NewGraph

func NewGraph[E any]() *Graph[E]

func (*Graph[E]) AddEdge

func (graph *Graph[E]) AddEdge(from, to string)

func (*Graph[E]) AddVertex

func (graph *Graph[E]) AddVertex(name string, elem E)

func (*Graph[E]) Check

func (graph *Graph[E]) Check() error

func (*Graph[E]) Optimize

func (graph *Graph[E]) Optimize()

func (*Graph[E]) Scheduling

func (graph *Graph[E]) Scheduling() (todo <-chan []*GraphVertex[E], done chan<- []*GraphVertex[E])

func (*Graph[E]) Steps

func (graph *Graph[E]) Steps() ([][]string, []string)

type GraphEdge

type GraphEdge[E any] struct {
	From *GraphVertex[E]
	To   *GraphVertex[E]
}

type GraphMarshaler

type GraphMarshaler[E any] struct {
	Vertices map[string]E
	Edges    [][2]string
}

func NewGraphMarshaler

func NewGraphMarshaler[E any](graph *Graph[E]) *GraphMarshaler[E]

func (GraphMarshaler[E]) GenerateGraph

func (marshaler GraphMarshaler[E]) GenerateGraph() *Graph[E]

type GraphVertex

type GraphVertex[E any] struct {
	Name   string
	Status int
	Elem   E

	Dependencies []*GraphVertex[E]
	Next         []*GraphVertex[E]
}

type Mapper

type Mapper[OE any, NE any] func(OE) (NE, error)

type WorkParams

type WorkParams struct {
	GorLimit         int
	ActionsBeforeRun map[string]ogcore.Action
	ActionsAfterRun  map[string]ogcore.Action
}

type Worker

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

func NewWorker

func NewWorker(graph *Graph[ogcore.Node]) *Worker

func (*Worker) Work

func (worker *Worker) Work(ctx context.Context, state ogcore.State, params *WorkParams) error

type WorkerCache

type WorkerCache struct {
	MaxSize int

	sync.Mutex
	// contains filtered or unexported fields
}

func (*WorkerCache) Get

func (cache *WorkerCache) Get() (*Worker, bool)

func (*WorkerCache) Put

func (cache *WorkerCache) Put(worker *Worker) bool

func (*WorkerCache) Reset

func (cache *WorkerCache) Reset()

type WorkerPool

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

func NewWorkerPool

func NewWorkerPool(cacheSize int) *WorkerPool

func (*WorkerPool) Get

func (pool *WorkerPool) Get() (*Worker, bool)

func (*WorkerPool) Put

func (pool *WorkerPool) Put(worker *Worker)

func (*WorkerPool) Reset

func (pool *WorkerPool) Reset()

Jump to

Keyboard shortcuts

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