Documentation
¶
Index ¶
- Variables
- func ConvertScriptOutput(rawOutput interface{}, expectedOutputs []string, scriptType string, ...) (map[string]interface{}, error)
- func ExecuteWithRecovery(ctx *ExecutionContext, executeFunc func() error, onError func(error))
- func IsNonNegative(value interface{}) error
- func IsPositive(value interface{}) error
- func IsValidDateRange(startDate, endDate time.Time) error
- func IsValidEmail(email string) error
- func IsValidPhoneNumber(phone string) error
- func IsValidURL(url string) error
- func ScriptErrorHandler(err error, scriptType string, script string, functionName string, ...) error
- func TestFunctionWithRecovery(functionType string, content string, inputs interface{}, outputs []string, ...) (map[string]interface{}, error)
- func ValidateInputDefinition(input types.Input) error
- func ValidateScriptSafety(script string, scriptType string) error
- func ValidateWithRecovery(functionType string, content string, log logger.Log, validateFunc func() error) (bool, error)
- type AsyncExecutor
- type AsyncResult
- type BaseExecutor
- type CSharpFuncs
- type CollectionDeleteFuncs
- type CollectionInsertFuncs
- type CollectionUpdateFuncs
- type ConcurrencyLimiter
- type EmailFuncs
- type EmailStru
- type EnhancedCSharpExecutor
- type EnhancedCSharpFuncs
- type EnhancedGoExprExecutor
- type EnhancedGoExprFuncs
- type EnhancedPythonExecutor
- type ExecutionContext
- type ExecutionGraph
- type ExecutionNode
- type Funcs
- func (f *Funcs) CancelExecution(errormessage string)
- func (f *Funcs) ConvertfromBytes(bytesbuffer []byte) map[string]interface{}
- func (f *Funcs) ConverttoBool(str string) bool
- func (f *Funcs) ConverttoDateTime(str string) time.Time
- func (f *Funcs) ConverttoFloat(str string) float64
- func (f *Funcs) ConverttoInt(str string) int
- func (f *Funcs) Execute()
- func (f *Funcs) HandleInputs() ([]string, []string, map[string]interface{}, error)
- func (f *Funcs) HandleInputsLegacy() ([]string, []string, map[string]interface{}, error)
- func (f *Funcs) SetInputs() ([]string, []string, map[string]interface{})
- func (f *Funcs) SetOutputs(outputs map[string]interface{})
- func (f *Funcs) SetfuncOutputs()
- func (f *Funcs) SetfuncSingleOutputs(outputs map[string]interface{})
- func (f *Funcs) Validate() (bool, error)
- type FunctionExecutor
- type GoExprFuncs
- type InputMapFuncs
- type InputMapper
- type InputProcessor
- func (ip *InputProcessor) GetBoolInput(inputs map[string]interface{}, key string, defaultValue bool) (bool, error)
- func (ip *InputProcessor) GetInputWithDefault(inputs map[string]interface{}, key string, defaultValue interface{}) interface{}
- func (ip *InputProcessor) GetIntInput(inputs map[string]interface{}, key string, defaultValue int) (int, error)
- func (ip *InputProcessor) GetStringInput(inputs map[string]interface{}, key string, defaultValue string) string
- func (ip *InputProcessor) ValidateInputs(inputs map[string]interface{}, requiredInputs []string) error
- type InputValidator
- func (iv *InputValidator) AddCustomRule(fieldName string, validatorFunc func(interface{}) error, message string)
- func (iv *InputValidator) AddEnumRule(fieldName string, allowedValues []string)
- func (iv *InputValidator) AddMaxLengthRule(fieldName string, maxLength int)
- func (iv *InputValidator) AddMaxValueRule(fieldName string, maxValue float64)
- func (iv *InputValidator) AddMinLengthRule(fieldName string, minLength int)
- func (iv *InputValidator) AddMinValueRule(fieldName string, minValue float64)
- func (iv *InputValidator) AddRegexRule(fieldName string, pattern string, message string)
- func (iv *InputValidator) AddRequiredRule(fieldName string)
- func (iv *InputValidator) AddRule(fieldName string, rule ValidationRule)
- func (iv *InputValidator) Validate(inputs map[string]interface{}) *ValidationResult
- type JSFuncs
- func (cf *JSFuncs) Execute(f *Funcs)
- func (cf *JSFuncs) Execute_otto(f *Funcs)
- func (cf *JSFuncs) Testfunction(content string, inputs interface{}, outputs []string) (map[string]interface{}, error)
- func (cf *JSFuncs) Testfunction_otto(content string, inputs interface{}, outputs []string) (map[string]interface{}, error)
- func (cf *JSFuncs) Validate(f *Funcs) (bool, error)
- func (cf *JSFuncs) Validate_otto(f *Funcs) (bool, error)
- type JSONHelper
- type OutputBuilder
- func (ob *OutputBuilder) Build() (map[string]interface{}, error)
- func (ob *OutputBuilder) GetOutputs() map[string]interface{}
- func (ob *OutputBuilder) Set(name string, value interface{}) *OutputBuilder
- func (ob *OutputBuilder) SetBool(name string, value interface{}) *OutputBuilder
- func (ob *OutputBuilder) SetDateTime(name string, value interface{}) *OutputBuilder
- func (ob *OutputBuilder) SetFloat(name string, value interface{}) *OutputBuilder
- func (ob *OutputBuilder) SetInt(name string, value interface{}) *OutputBuilder
- func (ob *OutputBuilder) SetString(name string, value interface{}) *OutputBuilder
- type OutputProcessor
- type ParallelExecutor
- type PythonExprFuncs
- type PythonScriptFuncs
- type QueryFuncs
- type Response
- type ScriptExecutionConfig
- type ScriptExecutionResult
- type ScriptExecutor
- type SendMessageFuncs
- type SendMessagebyActiveMQ
- type SendMessagebyKafka
- type SendMessagebyMQTT
- type SessionHelper
- func (sh *SessionHelper) GetSystemInt(key string, defaultValue int) int
- func (sh *SessionHelper) GetSystemString(key, defaultValue string) string
- func (sh *SessionHelper) GetUserInt(key string, defaultValue int) int
- func (sh *SessionHelper) GetUserString(key, defaultValue string) string
- func (sh *SessionHelper) SetSystemValue(key string, value interface{})
- func (sh *SessionHelper) SetUserValue(key string, value interface{})
- type SliceHelper
- type StoreProcFuncs
- type StringHelper
- type SubTranCode
- type SubTranCodeFuncs
- type TableDeleteFuncs
- type TableInsertFuncs
- type TableUpdateFuncs
- type ThrowErrorFuncs
- type TranFlow
- type TypeConverter
- func (tc *TypeConverter) ConvertToBool(value interface{}) (bool, error)
- func (tc *TypeConverter) ConvertToDateTime(value interface{}) (time.Time, error)
- func (tc *TypeConverter) ConvertToFloat(value interface{}) (float64, error)
- func (tc *TypeConverter) ConvertToInt(value interface{}) (int, error)
- func (tc *TypeConverter) ConvertToString(value interface{}) string
- type ValidationError
- type ValidationResult
- type ValidationRule
- type ValidationType
- type WebServiceCallFunc
- type WorkFlowFunc
- type WorkerPool
Constants ¶
This section is empty.
Variables ¶
var JSON = &JSONHelper{}
Global JSON helper instance
var Slice = &SliceHelper{}
Global slice helper instance
var Str = &StringHelper{}
Global string helper instance
var TypeConv = &TypeConverter{}
Global type converter instance
Functions ¶
func ConvertScriptOutput ¶
func ConvertScriptOutput(
rawOutput interface{},
expectedOutputs []string,
scriptType string,
log logger.Log,
) (map[string]interface{}, error)
ConvertScriptOutput safely converts script output to expected format
func ExecuteWithRecovery ¶
func ExecuteWithRecovery( ctx *ExecutionContext, executeFunc func() error, onError func(error), )
ExecuteWithRecovery executes a function with standard panic recovery and logging This eliminates the duplication of defer/recover patterns across all Execute functions
func IsNonNegative ¶
func IsNonNegative(value interface{}) error
IsNonNegative validates that a number is non-negative
func IsPositive ¶
func IsPositive(value interface{}) error
IsPositive validates that a number is positive
func IsValidDateRange ¶
IsValidDateRange validates that start date is before end date
func IsValidPhoneNumber ¶
IsValidPhoneNumber validates phone number format (simple validation)
func ScriptErrorHandler ¶
func ScriptErrorHandler( err error, scriptType string, script string, functionName string, startTime time.Time, log logger.Log, ) error
ScriptErrorHandler handles errors from script execution and converts them to BPMErrors
func TestFunctionWithRecovery ¶
func TestFunctionWithRecovery( functionType string, content string, inputs interface{}, outputs []string, log logger.Log, testFunc func() (map[string]interface{}, error), ) (map[string]interface{}, error)
TestFunctionWithRecovery executes test function with standard panic recovery
func ValidateInputDefinition ¶
ValidateInputDefinition validates that an input definition is correctly configured
func ValidateScriptSafety ¶
ValidateScriptSafety performs basic safety checks on script content
Types ¶
type AsyncExecutor ¶
type AsyncExecutor struct {
// contains filtered or unexported fields
}
AsyncExecutor executes functions asynchronously and returns results via channels
func NewAsyncExecutor ¶
func NewAsyncExecutor(workers int, log logger.Log) *AsyncExecutor
NewAsyncExecutor creates a new async executor
func (*AsyncExecutor) ExecuteAsync ¶
func (ae *AsyncExecutor) ExecuteAsync(ctx context.Context, fn *types.Function, executor FunctionExecutor) <-chan AsyncResult
ExecuteAsync executes a function asynchronously
func (*AsyncExecutor) Shutdown ¶
func (ae *AsyncExecutor) Shutdown()
Shutdown gracefully shuts down the async executor
type AsyncResult ¶
AsyncResult holds the result of an async execution
type BaseExecutor ¶
BaseExecutor provides common functionality for all function executors
func NewBaseExecutor ¶
func NewBaseExecutor(functionType string, log logger.Log) *BaseExecutor
NewBaseExecutor creates a new BaseExecutor
func (*BaseExecutor) ExecuteFunction ¶
func (be *BaseExecutor) ExecuteFunction( f *Funcs, executionLogic func(inputs map[string]interface{}) (map[string]interface{}, error), )
ExecuteFunction is a template method for function execution
type CSharpFuncs ¶
type CSharpFuncs struct {
}
func (*CSharpFuncs) Execute ¶
func (cf *CSharpFuncs) Execute(f *Funcs)
func (*CSharpFuncs) Testfunction ¶
func (cf *CSharpFuncs) Testfunction(content string, inputs interface{}, outputs []string) (map[string]interface{}, error)
type CollectionDeleteFuncs ¶
type CollectionDeleteFuncs struct {
}
func (*CollectionDeleteFuncs) Execute ¶
func (cf *CollectionDeleteFuncs) Execute(f *Funcs)
type CollectionInsertFuncs ¶
type CollectionInsertFuncs struct {
}
func (*CollectionInsertFuncs) Execute ¶
func (cf *CollectionInsertFuncs) Execute(f *Funcs)
type CollectionUpdateFuncs ¶
type CollectionUpdateFuncs struct {
}
func (*CollectionUpdateFuncs) Execute ¶
func (cf *CollectionUpdateFuncs) Execute(f *Funcs)
type ConcurrencyLimiter ¶
type ConcurrencyLimiter struct {
// contains filtered or unexported fields
}
ConcurrencyLimiter limits concurrent operations
func NewConcurrencyLimiter ¶
func NewConcurrencyLimiter(maxConcurrent int) *ConcurrencyLimiter
NewConcurrencyLimiter creates a new concurrency limiter
func (*ConcurrencyLimiter) Acquire ¶
func (cl *ConcurrencyLimiter) Acquire()
Acquire acquires a slot for concurrent execution
func (*ConcurrencyLimiter) Execute ¶
func (cl *ConcurrencyLimiter) Execute(fn func())
Execute executes a function with concurrency limiting
func (*ConcurrencyLimiter) Release ¶
func (cl *ConcurrencyLimiter) Release()
Release releases a slot
type EmailFuncs ¶
type EmailFuncs struct{}
func (*EmailFuncs) Execute ¶
func (cf *EmailFuncs) Execute(f *Funcs)
Execute executes the SendEmail function. It validates the email configuration, sets up the email parameters, and sends the email using the provided SMTP server. If an attachment is specified, it sends the email with the attachment, otherwise it sends the email without any attachment.
func (*EmailFuncs) Validate ¶
func (cf *EmailFuncs) Validate(f *Funcs) (bool, EmailStru)
Validate validates the inputs for sending an email. It checks if the required fields (ToEmails, Subject, Body) are not empty. If any of the required fields are empty, it returns false along with the empty email structure. Otherwise, it returns true along with the populated email structure.
type EnhancedCSharpExecutor ¶
type EnhancedCSharpExecutor struct {
Config *ScriptExecutionConfig
Log logger.Log
DotnetPath string // Path to dotnet executable
}
EnhancedCSharpExecutor provides enhanced C# code execution with safety and performance features
func NewEnhancedCSharpExecutor ¶
func NewEnhancedCSharpExecutor(config *ScriptExecutionConfig, log logger.Log) *EnhancedCSharpExecutor
NewEnhancedCSharpExecutor creates a new enhanced C# executor
func (*EnhancedCSharpExecutor) Execute ¶
func (e *EnhancedCSharpExecutor) Execute( ctx context.Context, script string, inputs map[string]interface{}, outputs []string, ) (map[string]interface{}, error)
Execute executes C# code with timeout and error handling
func (*EnhancedCSharpExecutor) GetType ¶
func (e *EnhancedCSharpExecutor) GetType() string
GetType returns the executor type
func (*EnhancedCSharpExecutor) Validate ¶
func (e *EnhancedCSharpExecutor) Validate(script string) error
Validate validates C# code syntax Note: This is a basic check. Full validation requires dotnet compilation
type EnhancedCSharpFuncs ¶
type EnhancedCSharpFuncs struct {
// contains filtered or unexported fields
}
EnhancedCSharpFuncs is the enhanced version of CSharpFuncs with better error handling
func (*EnhancedCSharpFuncs) Execute ¶
func (cf *EnhancedCSharpFuncs) Execute(f *Funcs)
Execute executes the enhanced C# function
func (*EnhancedCSharpFuncs) Testfunction ¶
func (cf *EnhancedCSharpFuncs) Testfunction( content string, inputs interface{}, outputs []string, ) (map[string]interface{}, error)
Testfunction tests the C# code with provided inputs
type EnhancedGoExprExecutor ¶
type EnhancedGoExprExecutor struct {
Config *ScriptExecutionConfig
Log logger.Log
}
EnhancedGoExprExecutor provides enhanced Go expression execution with safety and performance features
func NewEnhancedGoExprExecutor ¶
func NewEnhancedGoExprExecutor(config *ScriptExecutionConfig, log logger.Log) *EnhancedGoExprExecutor
NewEnhancedGoExprExecutor creates a new enhanced Go expression executor
func (*EnhancedGoExprExecutor) Execute ¶
func (e *EnhancedGoExprExecutor) Execute( ctx context.Context, script string, inputs map[string]interface{}, outputs []string, ) (map[string]interface{}, error)
Execute executes a Go expression with timeout and error handling
func (*EnhancedGoExprExecutor) GetType ¶
func (e *EnhancedGoExprExecutor) GetType() string
GetType returns the executor type
func (*EnhancedGoExprExecutor) Validate ¶
func (e *EnhancedGoExprExecutor) Validate(script string) error
Validate validates a Go expression syntax
type EnhancedGoExprFuncs ¶
type EnhancedGoExprFuncs struct {
// contains filtered or unexported fields
}
EnhancedGoExprFuncs is the enhanced version of GoExprFuncs with better error handling
func (*EnhancedGoExprFuncs) Execute ¶
func (cf *EnhancedGoExprFuncs) Execute(f *Funcs)
Execute executes the enhanced Go expression function
func (*EnhancedGoExprFuncs) Testfunction ¶
func (cf *EnhancedGoExprFuncs) Testfunction( content string, inputs interface{}, outputs []string, ) (map[string]interface{}, error)
Testfunction tests the Go expression with provided inputs
type EnhancedPythonExecutor ¶
type EnhancedPythonExecutor struct {
Config *ScriptExecutionConfig
Log logger.Log
PythonPath string // Path to python executable (python3)
IsExpr bool // true for expression evaluation, false for full script
}
EnhancedPythonExecutor provides Python code execution with safety and performance features
func NewEnhancedPythonExecutor ¶
func NewEnhancedPythonExecutor(config *ScriptExecutionConfig, isExpr bool, log logger.Log) *EnhancedPythonExecutor
NewEnhancedPythonExecutor creates a new enhanced Python executor
func (*EnhancedPythonExecutor) Execute ¶
func (e *EnhancedPythonExecutor) Execute( ctx context.Context, script string, inputs map[string]interface{}, outputs []string, ) (map[string]interface{}, error)
Execute executes Python code/expression with timeout and error handling
func (*EnhancedPythonExecutor) GetType ¶
func (e *EnhancedPythonExecutor) GetType() string
GetType returns the executor type
func (*EnhancedPythonExecutor) Validate ¶
func (e *EnhancedPythonExecutor) Validate(script string) error
Validate validates Python code syntax
type ExecutionContext ¶
type ExecutionContext struct {
FunctionName string
FunctionType string
StartTime time.Time
Log logger.Log
}
ExecutionContext provides common context for function execution
type ExecutionGraph ¶
type ExecutionGraph struct {
Nodes map[string]*ExecutionNode
ExecutionOrder [][]string // Groups of functions that can execute in parallel
MaxConcurrency int
Timeout time.Duration
Log logger.Log
// contains filtered or unexported fields
}
ExecutionGraph manages parallel function execution with dependency resolution
func NewExecutionGraph ¶
NewExecutionGraph creates a new execution graph
func (*ExecutionGraph) AddFunction ¶
func (eg *ExecutionGraph) AddFunction(fn *types.Function, dependencies []string)
AddFunction adds a function to the execution graph
func (*ExecutionGraph) BuildExecutionOrder ¶
func (eg *ExecutionGraph) BuildExecutionOrder() error
BuildExecutionOrder performs topological sort to determine parallel execution groups
func (*ExecutionGraph) ExecuteParallel ¶
func (eg *ExecutionGraph) ExecuteParallel(ctx context.Context) error
ExecuteParallel executes functions in parallel according to dependency order
func (*ExecutionGraph) GetResults ¶
func (eg *ExecutionGraph) GetResults() map[string]map[string]interface{}
GetResults retrieves the outputs from all executed functions
type ExecutionNode ¶
type ExecutionNode struct {
Function *types.Function
Dependencies []string // Names of functions this depends on
Outputs map[string]interface{}
Error error
Executed bool
// contains filtered or unexported fields
}
ExecutionNode represents a function in the execution graph
type Funcs ¶
type Funcs struct {
Fobj types.Function
DBTx *sql.Tx
Ctx context.Context
CtxCancel context.CancelFunc
SystemSession map[string]interface{} // {sessionanme: value}
UserSession map[string]interface{} // {sessionanme: value}
Externalinputs map[string]interface{} // {sessionanme: value}
Externaloutputs map[string]interface{} // {sessionanme: value}
FuncCachedVariables map[string]interface{}
FunctionInputs []map[string]interface{}
FunctionOutputs []map[string]interface{}
ExecutionNumber int
ExecutionCount int
FunctionMappedInputs map[string]interface{}
DocDBCon *documents.DocDB
SignalRClient signalr.Client
ErrorMessage string
TestwithSc bool
TestResults []map[string]interface{}
// contains filtered or unexported fields
}
func (*Funcs) CancelExecution ¶
CancelExecution cancels the execution of the function and rolls back any database transaction. It takes an error message as input and logs the error message along with the function name. It also cancels the context and returns.
func (*Funcs) ConvertfromBytes ¶
func (*Funcs) ConverttoBool ¶
ConverttoBool converts a string to bool (uses TypeConverter for better error handling)
func (*Funcs) ConverttoDateTime ¶
ConverttoDateTime converts a string to time.Time (uses TypeConverter for better error handling)
func (*Funcs) ConverttoFloat ¶
ConverttoFloat converts a string to float64 (uses TypeConverter for better error handling)
func (*Funcs) ConverttoInt ¶
ConverttoInt converts a string to int (uses TypeConverter for better error handling)
func (*Funcs) Execute ¶
func (f *Funcs) Execute()
Execute executes the function. It measures the execution time, handles panics, and executes the appropriate function based on the function type. It also sets the function outputs and updates the execution count.
func (*Funcs) HandleInputs ¶
func (*Funcs) HandleInputsLegacy ¶
HandleInputsLegacy is the original HandleInputs implementation kept for backward compatibility This function is deprecated and will be removed in a future version Use HandleInputs instead, which uses the new comprehensive InputMapper
func (*Funcs) SetOutputs ¶
func (*Funcs) SetfuncOutputs ¶
func (f *Funcs) SetfuncOutputs()
func (*Funcs) SetfuncSingleOutputs ¶
SetfuncSingleOutputs sets the single outputs of the Funcs object based on the provided map of outputs. It iterates through the outputs of the Funcs object and assigns the corresponding values from the map to the appropriate destinations. The UserSession, Externaloutputs, and FuncCachedVariables are updated accordingly. If an error occurs during the process, it is recovered and logged. The performance duration of the function is also logged. Parameters: - outputs: A map of string keys and interface{} values representing the outputs. Returns: - An error if there was an error in the process.
type FunctionExecutor ¶
type FunctionExecutor interface {
Execute(ctx context.Context, fn *types.Function, inputs map[string]interface{}) (map[string]interface{}, error)
}
FunctionExecutor defines how to execute a single function
type GoExprFuncs ¶
type GoExprFuncs struct {
}
func (*GoExprFuncs) Execute ¶
func (cf *GoExprFuncs) Execute(f *Funcs)
func (*GoExprFuncs) Testfunction ¶
func (cf *GoExprFuncs) Testfunction(content string, inputs interface{}, outputs []string) (map[string]interface{}, error)
type InputMapFuncs ¶
type InputMapFuncs struct{}
func (*InputMapFuncs) Execute ¶
func (cf *InputMapFuncs) Execute(f *Funcs)
func (*InputMapFuncs) Validate ¶
func (cf *InputMapFuncs) Validate(f *Funcs) bool
type InputMapper ¶
type InputMapper struct {
SystemSession map[string]interface{}
UserSession map[string]interface{}
Externalinputs map[string]interface{}
FuncCachedVariables map[string]interface{}
Log logger.Log
}
InputMapper handles comprehensive input mapping and validation
func NewInputMapper ¶
func NewInputMapper(systemSession, userSession, externalInputs, funcCachedVariables map[string]interface{}, log logger.Log) *InputMapper
NewInputMapper creates a new InputMapper instance
func (*InputMapper) MapAllInputs ¶
func (im *InputMapper) MapAllInputs(inputs []types.Input) (map[string]interface{}, []string, []string, error)
MapAllInputs maps all inputs from a function definition
type InputProcessor ¶
InputProcessor handles common input processing logic
func NewInputProcessor ¶
func NewInputProcessor(log logger.Log) *InputProcessor
NewInputProcessor creates a new InputProcessor
func (*InputProcessor) GetBoolInput ¶
func (ip *InputProcessor) GetBoolInput( inputs map[string]interface{}, key string, defaultValue bool, ) (bool, error)
GetBoolInput safely gets a bool input
func (*InputProcessor) GetInputWithDefault ¶
func (ip *InputProcessor) GetInputWithDefault( inputs map[string]interface{}, key string, defaultValue interface{}, ) interface{}
GetInputWithDefault gets an input value with a default
func (*InputProcessor) GetIntInput ¶
func (ip *InputProcessor) GetIntInput( inputs map[string]interface{}, key string, defaultValue int, ) (int, error)
GetIntInput safely gets an int input
func (*InputProcessor) GetStringInput ¶
func (ip *InputProcessor) GetStringInput( inputs map[string]interface{}, key string, defaultValue string, ) string
GetStringInput safely gets a string input
func (*InputProcessor) ValidateInputs ¶
func (ip *InputProcessor) ValidateInputs( inputs map[string]interface{}, requiredInputs []string, ) error
ValidateInputs validates that all required inputs are present
type InputValidator ¶
type InputValidator struct {
Rules map[string][]ValidationRule
}
InputValidator handles comprehensive input validation
func NewInputValidator ¶
func NewInputValidator() *InputValidator
NewInputValidator creates a new InputValidator
func (*InputValidator) AddCustomRule ¶
func (iv *InputValidator) AddCustomRule(fieldName string, validatorFunc func(interface{}) error, message string)
AddCustomRule adds a custom validation function
func (*InputValidator) AddEnumRule ¶
func (iv *InputValidator) AddEnumRule(fieldName string, allowedValues []string)
AddEnumRule adds an enum validation rule (value must be in allowed list)
func (*InputValidator) AddMaxLengthRule ¶
func (iv *InputValidator) AddMaxLengthRule(fieldName string, maxLength int)
AddMaxLengthRule adds a maximum length validation rule
func (*InputValidator) AddMaxValueRule ¶
func (iv *InputValidator) AddMaxValueRule(fieldName string, maxValue float64)
AddMaxValueRule adds a maximum value validation rule (for numbers)
func (*InputValidator) AddMinLengthRule ¶
func (iv *InputValidator) AddMinLengthRule(fieldName string, minLength int)
AddMinLengthRule adds a minimum length validation rule
func (*InputValidator) AddMinValueRule ¶
func (iv *InputValidator) AddMinValueRule(fieldName string, minValue float64)
AddMinValueRule adds a minimum value validation rule (for numbers)
func (*InputValidator) AddRegexRule ¶
func (iv *InputValidator) AddRegexRule(fieldName string, pattern string, message string)
AddRegexRule adds a regex pattern validation rule
func (*InputValidator) AddRequiredRule ¶
func (iv *InputValidator) AddRequiredRule(fieldName string)
AddRequiredRule adds a required validation rule
func (*InputValidator) AddRule ¶
func (iv *InputValidator) AddRule(fieldName string, rule ValidationRule)
AddRule adds a validation rule for a specific input field
func (*InputValidator) Validate ¶
func (iv *InputValidator) Validate(inputs map[string]interface{}) *ValidationResult
Validate validates all inputs against their rules
type JSFuncs ¶
type JSFuncs struct {
}
func (*JSFuncs) Execute ¶
Execute executes the JavaScript function defined in the Funcs object. It sets the inputs, runs the JavaScript code, and sets the outputs. If there is an error during execution, it logs the error and returns. The execution time is also logged.
func (*JSFuncs) Execute_otto ¶
func (*JSFuncs) Testfunction ¶
func (cf *JSFuncs) Testfunction(content string, inputs interface{}, outputs []string) (map[string]interface{}, error)
Testfunction is a function that executes JavaScript code using the goja VM. It takes a content string, inputs interface{}, and outputs []string as parameters. The function returns a map[string]interface{} containing the values of the specified outputs, and an error if there was an error during execution. The execution time is also logged.
func (*JSFuncs) Testfunction_otto ¶
type JSONHelper ¶
type JSONHelper struct{}
JSONHelper provides JSON marshaling/unmarshaling utilities
func (*JSONHelper) Marshal ¶
func (jh *JSONHelper) Marshal(value interface{}) (string, error)
Marshal safely marshals a value to JSON string
func (*JSONHelper) MarshalIndent ¶
func (jh *JSONHelper) MarshalIndent(value interface{}) (string, error)
MarshalIndent marshals with indentation for readability
func (*JSONHelper) Unmarshal ¶
func (jh *JSONHelper) Unmarshal(jsonStr string) (map[string]interface{}, error)
Unmarshal safely unmarshals JSON string to map
func (*JSONHelper) UnmarshalToSlice ¶
func (jh *JSONHelper) UnmarshalToSlice(jsonStr string) ([]interface{}, error)
UnmarshalToSlice safely unmarshals JSON string to slice
type OutputBuilder ¶
type OutputBuilder struct {
// contains filtered or unexported fields
}
OutputBuilder helps build output maps with validation
func NewOutputBuilder ¶
func NewOutputBuilder() *OutputBuilder
NewOutputBuilder creates a new OutputBuilder
func (*OutputBuilder) Build ¶
func (ob *OutputBuilder) Build() (map[string]interface{}, error)
Build returns the output map and any errors encountered
func (*OutputBuilder) GetOutputs ¶
func (ob *OutputBuilder) GetOutputs() map[string]interface{}
GetOutputs returns the outputs map (even if there were errors)
func (*OutputBuilder) Set ¶
func (ob *OutputBuilder) Set(name string, value interface{}) *OutputBuilder
Set sets an output value with optional type validation
func (*OutputBuilder) SetBool ¶
func (ob *OutputBuilder) SetBool(name string, value interface{}) *OutputBuilder
SetBool sets a bool output with validation
func (*OutputBuilder) SetDateTime ¶
func (ob *OutputBuilder) SetDateTime(name string, value interface{}) *OutputBuilder
SetDateTime sets a datetime output with validation
func (*OutputBuilder) SetFloat ¶
func (ob *OutputBuilder) SetFloat(name string, value interface{}) *OutputBuilder
SetFloat sets a float output with validation
func (*OutputBuilder) SetInt ¶
func (ob *OutputBuilder) SetInt(name string, value interface{}) *OutputBuilder
SetInt sets an int output with validation
func (*OutputBuilder) SetString ¶
func (ob *OutputBuilder) SetString(name string, value interface{}) *OutputBuilder
SetString sets a string output with validation
type OutputProcessor ¶
OutputProcessor handles common output processing logic
func NewOutputProcessor ¶
func NewOutputProcessor(log logger.Log) *OutputProcessor
NewOutputProcessor creates a new OutputProcessor
func (*OutputProcessor) ProcessOutputs ¶
func (op *OutputProcessor) ProcessOutputs( rawOutputs interface{}, outputDefs []types.Output, ) (map[string]interface{}, error)
ProcessOutputs extracts outputs from a function based on output definitions
type ParallelExecutor ¶
type ParallelExecutor struct {
// contains filtered or unexported fields
}
ParallelExecutor executes a batch of functions in parallel
func NewParallelExecutor ¶
func NewParallelExecutor(maxConcurrency int, timeout time.Duration, log logger.Log) *ParallelExecutor
NewParallelExecutor creates a new parallel executor
func (*ParallelExecutor) ExecuteBatch ¶
func (pe *ParallelExecutor) ExecuteBatch(ctx context.Context, functions []*types.Function, executor FunctionExecutor) ([]map[string]interface{}, []error)
ExecuteBatch executes a batch of independent functions in parallel
type PythonExprFuncs ¶
type PythonExprFuncs struct {
// contains filtered or unexported fields
}
PythonExprFuncs handles Python expression evaluation
func (*PythonExprFuncs) Execute ¶
func (cf *PythonExprFuncs) Execute(f *Funcs)
Execute executes the Python expression
func (*PythonExprFuncs) Testfunction ¶
func (cf *PythonExprFuncs) Testfunction(content string, inputs interface{}, outputs []string) (map[string]interface{}, error)
Testfunction tests the Python expression
type PythonScriptFuncs ¶
type PythonScriptFuncs struct {
// contains filtered or unexported fields
}
PythonScriptFuncs handles Python script execution
func (*PythonScriptFuncs) Execute ¶
func (cf *PythonScriptFuncs) Execute(f *Funcs)
Execute executes the Python script
func (*PythonScriptFuncs) Testfunction ¶
func (cf *PythonScriptFuncs) Testfunction(content string, inputs interface{}, outputs []string) (map[string]interface{}, error)
Testfunction tests the Python script
type QueryFuncs ¶
type QueryFuncs struct {
}
func (*QueryFuncs) Execute ¶
func (cf *QueryFuncs) Execute(f *Funcs)
Execute executes the query function. It measures the execution time and logs performance metrics. If there is an error during execution, it logs the error and sets the error message. It sets the user session and creates a SELECT clause with aliases. It performs the query operation using the provided database connection. It logs the outputs, column count, and row count. Finally, it sets the outputs of the function.
func (*QueryFuncs) Testfunction ¶
func (cf *QueryFuncs) Testfunction(f *Funcs) (bool, error)
type ScriptExecutionConfig ¶
type ScriptExecutionConfig struct {
Timeout time.Duration
MaxMemoryMB int
AllowedModules []string
SandboxEnabled bool
}
ScriptExecutionConfig holds configuration for script execution
func DefaultScriptConfig ¶
func DefaultScriptConfig() *ScriptExecutionConfig
DefaultScriptConfig returns default script execution configuration
type ScriptExecutionResult ¶
type ScriptExecutionResult struct {
Outputs map[string]interface{}
ExecutionTime time.Duration
MemoryUsed int64
Error error
}
ScriptExecutionResult holds the result of script execution
func ExecuteScriptWithTimeout ¶
func ExecuteScriptWithTimeout( executor ScriptExecutor, ctx context.Context, script string, inputs map[string]interface{}, outputs []string, timeout time.Duration, log logger.Log, ) (*ScriptExecutionResult, error)
ExecuteScriptWithTimeout executes a script with timeout and returns structured result
type ScriptExecutor ¶
type ScriptExecutor interface {
Execute(ctx context.Context, script string, inputs map[string]interface{}, outputs []string) (map[string]interface{}, error)
Validate(script string) error
GetType() string
}
ScriptExecutor provides a common interface for all script executors
type SendMessageFuncs ¶
type SendMessageFuncs struct {
}
func (*SendMessageFuncs) Execute ¶
func (cf *SendMessageFuncs) Execute(f *Funcs)
Execute executes the SendMessageFuncs function. It sets the start time, defers the calculation of elapsed time and logging of performance, and recovers from any panics that occur during execution. It retrieves the inputs, sets the topic and data, and marshals the data into JSON format. If the topic is empty, it logs an error and returns. It then invokes the SignalRClient or IACMessageBusClient to send the message. Finally, it sets the outputs of the function.
func (*SendMessageFuncs) Validate ¶
func (cf *SendMessageFuncs) Validate(f *Funcs) (bool, error)
Validate validates the SendMessageFuncs function. It checks if the namelist and valuelist are empty, and if the "Topic" name is present in the namelist. Returns true if the validation passes, otherwise returns false with an error. It also logs the performance of the function.
type SendMessagebyActiveMQ ¶
type SendMessagebyActiveMQ struct {
}
func (*SendMessagebyActiveMQ) Execute ¶
func (w *SendMessagebyActiveMQ) Execute(f *Funcs)
type SendMessagebyKafka ¶
type SendMessagebyKafka struct {
}
func (*SendMessagebyKafka) Execute ¶
func (cf *SendMessagebyKafka) Execute(f *Funcs)
func (*SendMessagebyKafka) Validate ¶
func (cf *SendMessagebyKafka) Validate(f *Funcs) (bool, error)
Validate validates the SendMessagebyKafka function. It checks if the namelist and valuelist are empty, and if the "Topic" name is present in the namelist. Returns true if the validation passes, otherwise returns false with an error. It also logs the performance of the function.
type SendMessagebyMQTT ¶
type SendMessagebyMQTT struct {
}
func (*SendMessagebyMQTT) Execute ¶
func (w *SendMessagebyMQTT) Execute(f *Funcs)
type SessionHelper ¶
type SessionHelper struct {
// contains filtered or unexported fields
}
SessionHelper provides convenient session operations
func NewSessionHelper ¶
func NewSessionHelper(systemSession, userSession map[string]interface{}) *SessionHelper
NewSessionHelper creates a new SessionHelper
func (*SessionHelper) GetSystemInt ¶
func (sh *SessionHelper) GetSystemInt(key string, defaultValue int) int
GetSystemInt gets an int from system session with default
func (*SessionHelper) GetSystemString ¶
func (sh *SessionHelper) GetSystemString(key, defaultValue string) string
GetSystemString gets a string from system session with default
func (*SessionHelper) GetUserInt ¶
func (sh *SessionHelper) GetUserInt(key string, defaultValue int) int
GetUserInt gets an int from user session with default
func (*SessionHelper) GetUserString ¶
func (sh *SessionHelper) GetUserString(key, defaultValue string) string
GetUserString gets a string from user session with default
func (*SessionHelper) SetSystemValue ¶
func (sh *SessionHelper) SetSystemValue(key string, value interface{})
SetSystemValue sets a value in system session
func (*SessionHelper) SetUserValue ¶
func (sh *SessionHelper) SetUserValue(key string, value interface{})
SetUserValue sets a value in user session
type SliceHelper ¶
type SliceHelper struct{}
SliceHelper provides slice manipulation utilities
func (*SliceHelper) ContainsInt ¶
func (sh *SliceHelper) ContainsInt(slice []int, value int) bool
ContainsInt checks if an int slice contains a value
func (*SliceHelper) ContainsString ¶
func (sh *SliceHelper) ContainsString(slice []string, value string) bool
ContainsString checks if a string slice contains a value
func (*SliceHelper) FilterStrings ¶
func (sh *SliceHelper) FilterStrings(slice []string, predicate func(string) bool) []string
FilterStrings filters a string slice by a predicate function
func (*SliceHelper) UniqueStrings ¶
func (sh *SliceHelper) UniqueStrings(slice []string) []string
UniqueStrings returns unique strings from a slice
type StoreProcFuncs ¶
type StoreProcFuncs struct {
}
func (*StoreProcFuncs) Execute ¶
func (cf *StoreProcFuncs) Execute(f *Funcs)
func (*StoreProcFuncs) Testfunction ¶
func (cf *StoreProcFuncs) Testfunction(f *Funcs) (bool, error)
type StringHelper ¶
type StringHelper struct{}
StringHelper provides string manipulation utilities
func (*StringHelper) DefaultIfEmpty ¶
func (sh *StringHelper) DefaultIfEmpty(s, defaultValue string) string
DefaultIfEmpty returns defaultValue if s is empty
func (*StringHelper) IsEmpty ¶
func (sh *StringHelper) IsEmpty(s string) bool
IsEmpty checks if a string is empty or whitespace only
func (*StringHelper) SplitAndTrim ¶
func (sh *StringHelper) SplitAndTrim(s, sep string) []string
SplitAndTrim splits a string and trims each part
type SubTranCode ¶
type SubTranCode struct {
}
type SubTranCodeFuncs ¶
type SubTranCodeFuncs struct {
TranFlowstr TranFlow
}
func NewSubTran ¶
func NewSubTran(tci TranFlow) *SubTranCodeFuncs
NewSubTran creates a new instance of SubTranCodeFuncs with the provided TranFlow. It returns a pointer to the newly created SubTranCodeFuncs.
func (*SubTranCodeFuncs) Execute ¶
func (cf *SubTranCodeFuncs) Execute(f *Funcs)
Execute executes the subtran function. It sets the inputs, retrieves the transaction code, and calls the callback function to execute the transaction code. The outputs are then converted and set as the function outputs. If there is an error during execution, it logs the error and sets the error message. It also logs the performance of the function.
func (*SubTranCodeFuncs) Validate ¶
func (cf *SubTranCodeFuncs) Validate(f *Funcs) (bool, error)
Validate is a method of the SubTranCodeFuncs struct that validates the function. It measures the performance of the function and logs the duration. It returns a boolean value indicating the success of the validation and an error if any. It also logs the performance of the function.
type TableDeleteFuncs ¶
type TableDeleteFuncs struct {
}
func (*TableDeleteFuncs) Execute ¶
func (cf *TableDeleteFuncs) Execute(f *Funcs)
Execute executes the TableDeleteFuncs function. It retrieves the input values, constructs the WHERE clause based on the key columns, and performs a table delete operation using the provided table name and WHERE clause. The result is stored in the "RowCount" output. If any error occurs during the execution, it is logged and returned.
func (*TableDeleteFuncs) Testfunction ¶
func (cf *TableDeleteFuncs) Testfunction(f *Funcs) (bool, error)
type TableInsertFuncs ¶
type TableInsertFuncs struct {
}
func (*TableInsertFuncs) Execute ¶
func (cf *TableInsertFuncs) Execute(f *Funcs)
func (*TableInsertFuncs) Testfunction ¶
func (cf *TableInsertFuncs) Testfunction(f *Funcs) (bool, error)
func (*TableInsertFuncs) Validate ¶
func (cf *TableInsertFuncs) Validate(f *Funcs) (bool, error)
Validate validates the TableInsertFuncs. It measures the performance of the function and logs the duration. It returns true if the validation is successful, otherwise it returns an error. It also logs the performance of the function.
type TableUpdateFuncs ¶
type TableUpdateFuncs struct {
}
func (*TableUpdateFuncs) Execute ¶
func (cf *TableUpdateFuncs) Execute(f *Funcs)
func (*TableUpdateFuncs) Testfunction ¶
func (cf *TableUpdateFuncs) Testfunction(f *Funcs) (bool, error)
type ThrowErrorFuncs ¶
type ThrowErrorFuncs struct {
}
func (*ThrowErrorFuncs) Execute ¶
func (cf *ThrowErrorFuncs) Execute(f *Funcs)
Execute executes the ThrowErrorFuncs function. This function is intentionally designed to trigger transaction rollback. When executed with iserror=true, it ensures the entire transaction is rolled back to prevent partial data changes, maintaining data integrity.
ROLLBACK DESIGN: - Creates a structured BPMError with full execution context - Rolls back the database transaction - Cancels the execution context - Panics with the error to propagate rollback up the call chain - Parent transcode will catch this panic and handle rollback
type TypeConverter ¶
type TypeConverter struct{}
TypeConverter provides common type conversion operations
func (*TypeConverter) ConvertToBool ¶
func (tc *TypeConverter) ConvertToBool(value interface{}) (bool, error)
ConvertToBool safely converts a value to bool with error handling
func (*TypeConverter) ConvertToDateTime ¶
func (tc *TypeConverter) ConvertToDateTime(value interface{}) (time.Time, error)
ConvertToDateTime safely converts a value to time.Time with error handling
func (*TypeConverter) ConvertToFloat ¶
func (tc *TypeConverter) ConvertToFloat(value interface{}) (float64, error)
ConvertToFloat safely converts a value to float64 with error handling
func (*TypeConverter) ConvertToInt ¶
func (tc *TypeConverter) ConvertToInt(value interface{}) (int, error)
ConvertToInt safely converts a value to int with error handling
func (*TypeConverter) ConvertToString ¶
func (tc *TypeConverter) ConvertToString(value interface{}) string
ConvertToString safely converts any value to string
type ValidationError ¶
type ValidationError struct {
Field string
Rule ValidationType
Message string
}
ValidationError represents a validation error
func (*ValidationError) Error ¶
func (ve *ValidationError) Error() string
Error returns the error message
type ValidationResult ¶
type ValidationResult struct {
IsValid bool
Errors []*ValidationError
}
ValidationResult holds the results of validation
func (*ValidationResult) AddError ¶
func (vr *ValidationResult) AddError(field string, rule ValidationType, message string)
AddError adds a validation error
func (*ValidationResult) GetErrorMessages ¶
func (vr *ValidationResult) GetErrorMessages() []string
GetErrorMessages returns all error messages
type ValidationRule ¶
type ValidationRule struct {
Type ValidationType
Param interface{}
Message string
}
ValidationRule defines a validation rule for an input
type ValidationType ¶
type ValidationType int
ValidationType defines the type of validation
const ( ValidationRequired ValidationType = iota ValidationMinLength ValidationMaxLength ValidationMinValue ValidationMaxValue ValidationRegex ValidationCustom ValidationEnum )
func (ValidationType) String ¶
func (vt ValidationType) String() string
String returns the string representation of ValidationType
type WebServiceCallFunc ¶
type WebServiceCallFunc struct{}
func (*WebServiceCallFunc) Execute ¶
func (w *WebServiceCallFunc) Execute(f *Funcs)
type WorkFlowFunc ¶
type WorkFlowFunc struct{}
func (*WorkFlowFunc) Execute_CompleteTask ¶
func (w *WorkFlowFunc) Execute_CompleteTask(f *Funcs)
func (*WorkFlowFunc) Execute_Explode ¶
func (w *WorkFlowFunc) Execute_Explode(f *Funcs)
func (*WorkFlowFunc) Execute_StartTask ¶
func (w *WorkFlowFunc) Execute_StartTask(f *Funcs)
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool manages a pool of workers for parallel execution
func NewWorkerPool ¶
func NewWorkerPool(workers int, log logger.Log) *WorkerPool
NewWorkerPool creates a new worker pool
func (*WorkerPool) Shutdown ¶
func (wp *WorkerPool) Shutdown()
Shutdown gracefully shuts down the worker pool
func (*WorkerPool) ShutdownNow ¶
func (wp *WorkerPool) ShutdownNow()
ShutdownNow forcefully shuts down the worker pool
func (*WorkerPool) Submit ¶
func (wp *WorkerPool) Submit(task func()) error
Submit submits a task to the worker pool
Source Files
¶
- TableDeleteFuncs.go
- TableInsertFuncs.go
- TableUpdateFuncs.go
- activemq.go
- collectionDeleteFuncs.go
- collectionInsertFuncs.go
- collectionUpdateFuncs.go
- common_execution.go
- csharpfuncs.go
- csharpfuncs_enhanced.go
- funcs.go
- goexprfuncs.go
- goexprfuncs_enhanced.go
- helpers.go
- inputmapfuns.go
- inputmapper.go
- inputvalidator.go
- jsfuncs.go
- kafkaproducer.go
- parallel_executor.go
- pythonfuncs.go
- queryfuncs.go
- scriptexecutor.go
- sendMessage.go
- sendemail.go
- sendmsgbymqtt.go
- storeprocfuncs.go
- subtc.go
- throwErrorFuncs.go
- webservice.go
- workflow.go