ogimpl

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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CMD = "CMD"

	Choose   = "Choose"
	Parallel = "Parallel"
	Race     = "Race"

	Async     = "Async"
	Condition = "Condition"
	Loop      = "Loop"
	Retry     = "Retry"
	Slient    = "Slient"
	Timeout   = "Timeout"
	Trace     = "Trace"
	Delay     = "Delay"
)
View Source
const (
	AllowRead = 1 << iota
	AllowWrite
)

Variables

View Source
var AsyncWrapperFactory = func() ogcore.Node {
	return &AsyncWrapper{}
}
View Source
var ChooseClusterFactory = func() ogcore.Node {
	return &ChooseCluster{}
}
View Source
var CmdNodeFactory = func() ogcore.Node {
	return &CmdNode{}
}
View Source
var ConditionWrapperFactory = func() ogcore.Node {
	return &ConditionWrapper{}
}
View Source
var DelayWrapperFactory = func() ogcore.Node {
	return &DelayWrapper{}
}
View Source
var ErrTimeout = errors.New("the running time exceeds the limit")
View Source
var LoopWrapperFactory = func() ogcore.Node {
	return &LoopWrapper{LoopTimes: 1}
}
View Source
var ParallelClusterFactory = func() ogcore.Node {
	return &ParallelCluster{}
}
View Source
var RaceClusterFactory = func() ogcore.Node {
	return &RaceCluster{}
}
View Source
var RetryWrapperFactory = func() ogcore.Node {
	return &RetryWrapper{MaxRetryTimes: 1}
}
View Source
var SlientWrapperFactory = NewSlientWrapper
View Source
var TimeoutWrapperFactory = func() ogcore.Node {
	return &TimeoutWrapper{}
}
View Source
var TraceWrapperFactory = func() ogcore.Node {
	return &TraceWrapper{}
}

Functions

func NewChooseClusterFactory

func NewChooseClusterFactory(
	chooseFn func(ctx context.Context, state ogcore.State) int,
) func() ogcore.Node

func NewConditionWrapperFactory

func NewConditionWrapperFactory(
	cond func(ctx context.Context, state ogcore.State) bool,
) func() ogcore.Node

func NewRetryWrapper

func NewRetryWrapper(times int) ogcore.Node

func NewSlientWrapper

func NewSlientWrapper() ogcore.Node

func NewTimeoutWrapper

func NewTimeoutWrapper(duration time.Duration) ogcore.Node

func SetTraceId

func SetTraceId(state ogcore.State, id string)

Types

type AsyncWrapper

type AsyncWrapper struct {
	ograph.BaseWrapper
	*slog.Logger
}

func (*AsyncWrapper) Run

func (wrapper *AsyncWrapper) Run(ctx context.Context, state ogcore.State) error

type ChooseCluster

type ChooseCluster struct {
	ograph.BaseCluster
	*slog.Logger

	ChooseNode string

	ChooseFn func(ctx context.Context, state ogcore.State) int
}

func (*ChooseCluster) Run

func (cluster *ChooseCluster) Run(ctx context.Context, state ogcore.State) error

type CmdNode

type CmdNode struct {
	ograph.BaseNode
	*slog.Logger

	Cmd  []string
	Env  []string
	Dir  string
	Path string
}

func (*CmdNode) CmdIsAllowed

func (node *CmdNode) CmdIsAllowed() bool

func (*CmdNode) Run

func (node *CmdNode) Run(ctx context.Context, state ogcore.State) error

type ConditionWrapper

type ConditionWrapper struct {
	ograph.BaseWrapper

	Switch string

	Condition func(ctx context.Context, state ogcore.State) bool
}

func (*ConditionWrapper) Run

func (wrapper *ConditionWrapper) Run(ctx context.Context, state ogcore.State) error

type DelayWrapper

type DelayWrapper struct {
	ograph.BaseWrapper

	Wait  time.Duration
	Until time.Time
}

func (*DelayWrapper) Run

func (wrapper *DelayWrapper) Run(ctx context.Context, state ogcore.State) error

type FastState

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

func NewFastState

func NewFastState() *FastState

func (*FastState) Get

func (state *FastState) Get(key any) (any, bool)

func (*FastState) Set

func (state *FastState) Set(key any, val any)

func (*FastState) Update

func (state *FastState) Update(key any, updateFunc func(val any) any)

type GuardState

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

func NewGuardState

func NewGuardState(state ogcore.State, guard func(key any) (flag int)) *GuardState

func (*GuardState) Get

func (state *GuardState) Get(key any) (any, bool)

func (*GuardState) Set

func (state *GuardState) Set(key any, val any)

func (*GuardState) Update

func (state *GuardState) Update(key any, updateFunc func(val any) any)

type LoopWrapper

type LoopWrapper struct {
	ograph.BaseWrapper

	LoopTimes int
}

func (*LoopWrapper) Run

func (wrapper *LoopWrapper) Run(ctx context.Context, state ogcore.State) error

type OverlayState

type OverlayState struct {
	Upper map[any]any
	Lower ogcore.State

	sync.RWMutex
}

func NewOverlayState

func NewOverlayState(state ogcore.State) *OverlayState

func (*OverlayState) Get

func (state *OverlayState) Get(key any) (any, bool)

func (*OverlayState) Set

func (state *OverlayState) Set(key any, val any)

func (*OverlayState) Sync

func (state *OverlayState) Sync()

func (*OverlayState) Update

func (state *OverlayState) Update(key any, updateFunc func(val any) any)

type ParallelCluster

type ParallelCluster struct {
	ograph.BaseCluster
}

func (*ParallelCluster) Run

func (cluster *ParallelCluster) Run(ctx context.Context, state ogcore.State) error

type RaceCluster

type RaceCluster struct {
	ograph.BaseCluster
	*slog.Logger

	StateIsolation bool
}

func (*RaceCluster) Run

func (cluster *RaceCluster) Run(ctx context.Context, state ogcore.State) error

type RetryWrapper

type RetryWrapper struct {
	ograph.BaseWrapper
	*slog.Logger

	MaxRetryTimes int
}

func (*RetryWrapper) Run

func (wrapper *RetryWrapper) Run(ctx context.Context, state ogcore.State) error

type SlientWrapper

type SlientWrapper struct {
	ograph.BaseWrapper
	*slog.Logger
}

func (*SlientWrapper) Run

func (wrapper *SlientWrapper) Run(ctx context.Context, state ogcore.State) error

type TimeoutWrapper

type TimeoutWrapper struct {
	ograph.BaseWrapper

	Timeout string
}

func (*TimeoutWrapper) Run

func (wrapper *TimeoutWrapper) Run(ctx context.Context, state ogcore.State) error

type TraceWrapper

type TraceWrapper struct {
	ograph.BaseWrapper
	*slog.Logger
}

func (*TraceWrapper) Run

func (wrapper *TraceWrapper) Run(ctx context.Context, state ogcore.State) error

Jump to

Keyboard shortcuts

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