components

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorEquals    = "eq"
	OperatorNotEquals = "ne"
	OperatorIn        = "in"
	OperatorNotIn     = "nin"
	OperatorIsNull    = "isNull"
	OperatorIsNotNull = "isNotNull"
	OperatorGt        = "gt"
	OperatorLt        = "lt"
	OperatorGe        = "ge"
	OperatorLe        = "le"
)
View Source
const (
	Success = "success"
	Failed  = "failed"

	Skip = "skip"

	True  = "true"
	False = "false"
)
View Source
const (
	Js = "Js" // Represents JavaScript scripting language.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchComponent

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

StartComponent 启动组件

func NewBranchComponent

func NewBranchComponent(config json.RawMessage) (*BranchComponent, error)

func (*BranchComponent) AnalyzeInputs

func (c *BranchComponent) AnalyzeInputs(ctx context.Context) (any, error)

func (*BranchComponent) Execute

func (c *BranchComponent) Execute(ctx context.Context, input any) (*core.Result, error)

func (*BranchComponent) Validate

func (c *BranchComponent) Validate() []core.ValidationError

type BranchConfig

type BranchConfig struct {
	Conditions []Condition `json:"conditions"`
}

type CodejsComponent

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

CodejsComponent 代码执行组件

func NewCodejsComponent

func NewCodejsComponent(config json.RawMessage) (*CodejsComponent, error)

func (*CodejsComponent) AnalyzeInputs

func (c *CodejsComponent) AnalyzeInputs(ctx context.Context) (any, error)

func (*CodejsComponent) Execute

func (c *CodejsComponent) Execute(ctx context.Context, input any) (*core.Result, error)

func (*CodejsComponent) Validate

func (c *CodejsComponent) Validate() []core.ValidationError

type CodejsConfig

type CodejsConfig struct {
	Code string `json:"code"`
}

type Component

type Component interface {
	Validate() []core.ValidationError
	AnalyzeInputs(ctx context.Context) (any, error)
	Execute(ctx context.Context, input any) (*core.Result, error)
}

Component 定义组件核心接口

func ComponentFactory

func ComponentFactory(nodeType string, nodeConfig *core.NodeDefinition) (Component, error)

ComponentFactory 组件工厂

type Condition

type Condition struct {
	Left     core.Inputs `json:"left"`
	Right    core.Inputs `json:"right"`
	Route    string      `json:"route"`
	Operator string      `json:"operator"`
}

type Config

type Config struct {
	Udf map[string]interface{}
}

type Cp

type Cp struct {
	Left     any    `json:"left"`
	Right    any    `json:"right"`
	Route    string `json:"route"`
	Operator string `json:"operator"`
}

type EndComponent

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

EndComponent 结束组件

func NewEndComponent

func NewEndComponent(config json.RawMessage) (*EndComponent, error)

func (*EndComponent) AnalyzeInputs

func (c *EndComponent) AnalyzeInputs(ctx context.Context) (any, error)

func (*EndComponent) Execute

func (c *EndComponent) Execute(ctx context.Context, input any) (*core.Result, error)

func (*EndComponent) Validate

func (c *EndComponent) Validate() []core.ValidationError

type EndConfig

type EndConfig struct {
	OutPutType string `json:"outPutType"` // 输出类型 json
}

type GojaJsEngine

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

GojaJsEngine goja js engine

func NewGojaJsEngine

func NewGojaJsEngine(jsScript string, fromVars map[string]interface{}) (*GojaJsEngine, error)

NewGojaJsEngine Create a new instance of the JavaScript engine

func (*GojaJsEngine) Execute

func (g *GojaJsEngine) Execute(functionName string, argumentList ...interface{}) (out interface{}, err error)

Execute Execute JavaScript script

func (*GojaJsEngine) NewVm

func (g *GojaJsEngine) NewVm(config Config, fromVars map[string]interface{}) *goja.Runtime

NewVm new a js VM

func (*GojaJsEngine) PreCompileJs

func (g *GojaJsEngine) PreCompileJs(config Config) error

PreCompileJs Precompiled UDF JavaScript file

func (*GojaJsEngine) Stop

func (g *GojaJsEngine) Stop()

type HTTPComponent

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

HTTPComponent HTTP请求组件

func NewHTTPComponent

func NewHTTPComponent(config json.RawMessage) (*HTTPComponent, error)

func (*HTTPComponent) AnalyzeInputs

func (c *HTTPComponent) AnalyzeInputs(ctx context.Context) (any, error)

func (*HTTPComponent) Execute

func (c *HTTPComponent) Execute(ctx context.Context, input any) (*core.Result, error)

func (*HTTPComponent) Validate

func (c *HTTPComponent) Validate() []core.ValidationError

type HTTPConfig

type HTTPConfig struct {
	URL     string        `json:"url"`
	Method  string        `json:"method"`
	Headers []core.Inputs `json:"headers"`
	Params  []core.Inputs `json:"params"`
	Body    []core.Inputs `json:"body,omitempty"`
	Retries int           `json:"retries"`
	Timeout int64         `json:"timeout"`
}

type HttpClient

type HttpClient struct {
	Timeout    time.Duration
	MaxRetries int
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(timeout time.Duration, maxRetries int) *HttpClient

NewHttpClient 复用单例 client

func (*HttpClient) DoRequest

func (h *HttpClient) DoRequest(opts RequestOptions) (int, []byte, error)

DoRequest 复用 Request/Response

type RequestOptions

type RequestOptions struct {
	Method  string
	URL     string
	Headers map[string]string
	Body    interface{}
	IsJSON  bool
}

RequestOptions 请求选项

type Script

type Script struct {
	// Type is the script type, default is Js.
	Type string
	// Content is the script content or custom function.
	Content interface{}
}

Script is used to register native functions or custom functions defined in Go.

type StartComponent

type StartComponent struct {
}

StartComponent 启动组件

func NewStartComponent

func NewStartComponent() (*StartComponent, error)

func (*StartComponent) AnalyzeInputs

func (c *StartComponent) AnalyzeInputs(ctx context.Context) (any, error)

func (*StartComponent) Execute

func (c *StartComponent) Execute(ctx context.Context, input any) (*core.Result, error)

func (*StartComponent) Validate

func (c *StartComponent) Validate() []core.ValidationError

Jump to

Keyboard shortcuts

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