internal

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: MIT Imports: 11 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]
	VertexSlice []*GraphVertex[E]
	ScheduleNum int

	sync.Mutex
	// contains filtered or unexported fields
}

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(interrupts iter.Seq[string], parallelismLimit int) (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 `json:"Vertices,omitempty"`
	Edges    [][2]string  `json:"Edges,omitempty"`

	SubGraphs map[string]*GraphMarshaler[E] `json:"SubGraphs,omitempty"`
}

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
	Wait   int
	Elem   E

	Dependencies []*GraphVertex[E]
	Next         []*GraphVertex[E]
	Group        []*GraphVertex[E]

	Priority int
}

type HasPriority added in v0.7.0

type HasPriority interface {
	GetPriority() int
}

type Mapper

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

type Transaction added in v0.7.0

type Transaction struct {
	Manager *TransactionManager

	Node ogcore.Transactional
}

func (*Transaction) Run added in v0.7.0

func (tx *Transaction) Run(ctx context.Context, state ogcore.State) error

type TransactionManager added in v0.7.0

type TransactionManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewTransactionManager added in v0.7.0

func NewTransactionManager() *TransactionManager

func (*TransactionManager) CommitAll added in v0.7.0

func (manager *TransactionManager) CommitAll()

func (*TransactionManager) Manage added in v0.7.0

func (manager *TransactionManager) Manage(txNode ogcore.Transactional) *Transaction

func (*TransactionManager) PreCommit added in v0.7.0

func (manager *TransactionManager) PreCommit(tx *Transaction)

func (*TransactionManager) RollbackAll added in v0.7.0

func (manager *TransactionManager) RollbackAll()

type WorkParams

type WorkParams struct {
	GorLimit   int
	Tracker    *ogcore.Tracker
	Interrupts iter.Seq[string]

	Pause        bool
	ContinueCond *sync.Cond
}

type Worker

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

func NewWorker

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

func (*Worker) SetTxManager added in v0.7.0

func (worker *Worker) SetTxManager(manager *TransactionManager)

func (*Worker) Work

func (worker *Worker) Work(ctx context.Context, state ogcore.State, params *WorkParams) (err 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