runtime

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusAdded    = StatusType("ADDED")
	StatusReady    = StatusType("READY")
	StatusRunning  = StatusType("RUNNING")
	StatusStopped  = StatusType("STOPPED")
	StatusKilled   = StatusType("KILLED")
	StatusCanceled = StatusType("CANCELED")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

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

Event is from the event trigger, it will be used to make the flow run

type Flow

type Flow struct {
	sync.RWMutex
	FlowBody
}

Flow

func (*Flow) AST

func (f *Flow) AST() *parser.AST

func (*Flow) GetStatistics

func (f *Flow) GetStatistics(seq int) *functionStatistics

GetStatistics returns the statistics of the function node, 'seq' is the sequence id of the function node.

func (*Flow) IsAdded

func (f *Flow) IsAdded() bool

func (*Flow) IsReady

func (f *Flow) IsReady() bool

func (*Flow) IsRunning

func (f *Flow) IsRunning() bool

func (*Flow) IsStopped

func (f *Flow) IsStopped() bool

func (*Flow) Refresh

func (f *Flow) Refresh() error

Refresh figures out the status and statistics of the flow based on the function statistics.

func (*Flow) RunQ

func (f *Flow) RunQ() *actuator.RunQueue

func (*Flow) ToReady

func (f *Flow) ToReady() error

ToReady set the flow to ready status, when they are stopped.

func (*Flow) ToRunning

func (f *Flow) ToRunning()

ToRunning set the flow to running status and the begin time of the last running

func (*Flow) ToStopped

func (f *Flow) ToStopped()

ToStopped set the flow to stopped status and figure out the duration of the last running

func (*Flow) WithLock

func (f *Flow) WithLock(exec func(body *FlowBody) error) error

WithLock read/write the fields of the flow with the lock.

type FlowBody

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

func (*FlowBody) Export

func (b *FlowBody) Export() exported.FlowRunningInsight

Export exports some statistics of the flow running to the service layer.

func (*FlowBody) SetCancel

func (b *FlowBody) SetCancel(cancel context.CancelFunc)

SetCancel set the context cancel function to the flow.

type FlowOption

type FlowOption func(*FlowBody)

func WithAfterFunc

func WithAfterFunc(_func func(nameid.ID) error) FlowOption

WithAfterFunc initializes the after call-back.

func WithBeforeFunc

func WithBeforeFunc(_func func(nameid.ID) error) FlowOption

WithBeforeFunc initializes the before call-back.

func WithCopyResources

func WithCopyResources(copy func() resource.Resources) FlowOption

WithCopyResources initializes the resources of the flow & function.

func WithCreateLogwriter

func WithCreateLogwriter(_func func(string) (io.Writer, error)) FlowOption

WithCreateLogwriter initializes the logger for flow & function write the log.

type Runtime

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

func New

func New() *Runtime

func (*Runtime) CancelFlow

func (rt *Runtime) CancelFlow(ctx context.Context, id nameid.ID) error

CancelFlow cancel the flow and make it into CANCELED status.

func (*Runtime) DeleteFlow

func (rt *Runtime) DeleteFlow(ctx context.Context, id nameid.ID) error

func (*Runtime) ExecFlow

func (rt *Runtime) ExecFlow(ctx context.Context, id nameid.ID) (err0 error)

ExecFlow execute a flow step by step.

func (*Runtime) FetchFlow

func (rt *Runtime) FetchFlow(ctx context.Context, id nameid.ID, do func(*FlowBody) error) error

FetchFlow get a flow, then access or handle it safety by the callback function

func (*Runtime) HasTrigger

func (rt *Runtime) HasTrigger(id nameid.ID) (bool, error)

HasTrigger check the flow has a trigger or not

func (*Runtime) InitFlow

func (rt *Runtime) InitFlow(ctx context.Context, id nameid.ID, opts ...FlowOption) error

InitFlow initialize the flow and make it into READY status.

func (*Runtime) MustReady

func (rt *Runtime) MustReady(ctx context.Context, id nameid.ID) error

MustReay is a thin wrapper of Stopped2Ready

func (*Runtime) ParseFlow

func (rt *Runtime) ParseFlow(ctx context.Context, id nameid.ID, rd io.Reader) error

ParseFlow parse one flowl source file, and add a flow into runtime, the argument 'rd' is a reader for a flow source file. After invoking this method, the flow's status is ADDED.

func (*Runtime) StartEventTrigger

func (rt *Runtime) StartEventTrigger(ctx context.Context, id nameid.ID) error

StartEventTrigger start the event trigger of a flow, every event trigger function will run in a goroutine When a event trigger returned without an error, will create and send a event to runtime

func (*Runtime) Stopped2Ready

func (rt *Runtime) Stopped2Ready(ctx context.Context, id nameid.ID) error

Stopped2Ready will reset the status of the flow and all nodes to ready, but only when all nodes are stopped When re-executing the flow, You need to call this method

type StatusType

type StatusType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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