ogcore

package
v0.0.0-...-b845b6b Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WithImplMap = func(impls map[string]string) CtxOp {
	return func(ctx *OGContext) {
		ctx.VirtualImpl = func(key string) string {
			return impls[key]
		}
	}
}

Functions

func GenActionsByIntr

func GenActionsByIntr(interrupters []Interrupter) (map[string]Action, map[string]Action)

func GetImplNodeName

func GetImplNodeName(ctx context.Context, vname string) string

Types

type Action

type Action func(ctx context.Context, state State) error

type Cloneable

type Cloneable interface {
	Node
	Clone() Cloneable
}

type Cluster

type Cluster interface {
	Join(nodes []Node)
}

type CtxOp

type CtxOp func(ctx *OGContext)

type Factories

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

func NewFactories

func NewFactories() *Factories

func (*Factories) Add

func (f *Factories) Add(name string, factory func() Node)

func (*Factories) Clear

func (f *Factories) Clear()

func (*Factories) Clone

func (f *Factories) Clone() *Factories

func (*Factories) Get

func (f *Factories) Get(name string) func() Node

func (*Factories) Remove

func (f *Factories) Remove(name string)

type ImplQueryKey

type ImplQueryKey string

type Initializeable

type Initializeable interface {
	Init(params map[string]any) error
}

type Interrupt

type Interrupt func(in InterruptCtx) (error, bool)

func NewInterrupt

func NewInterrupt(handler InterruptHandler) Interrupt

type InterruptCtx

type InterruptCtx struct {
	context.Context

	From  string
	State State
}

func NewInterruptCtx

func NewInterruptCtx(ctx context.Context, from string, state State) InterruptCtx

type InterruptHandler

type InterruptHandler func(in InterruptCtx, yield func(error) InterruptCtx) error

type Interrupter

type Interrupter struct {
	Handler InterruptHandler
	Points  []string
}

type Nameable

type Nameable interface {
	Name() string

	SetName(name string)
}

type Node

type Node interface {
	Run(ctx context.Context, state State) error
}

type OGContext

type OGContext struct {
	context.Context

	VirtualImpl func(key string) string
	MatchedImpl map[string]string
}

func NewOGCtx

func NewOGCtx(parent context.Context, ops ...CtxOp) *OGContext

func (*OGContext) Value

func (ctx *OGContext) Value(key any) any

type State

type State interface {
	Get(key any) (any, bool)
	Set(key any, val any)
	Update(key any, updateFunc func(val any) any)
}

type VirtualNode

type VirtualNode struct {
	VirtualName string
	DefaultImpl string
	Implements  map[string]Node
}

func (*VirtualNode) Name

func (vn *VirtualNode) Name() string

func (*VirtualNode) Run

func (vn *VirtualNode) Run(ctx context.Context, state State) error

type Wrapper

type Wrapper interface {
	Wrap(node Node)
}

Jump to

Keyboard shortcuts

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