utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownValidationError = fmt.Errorf("unknown validation error")

Functions

func CanBeInt added in v0.2.0

func CanBeInt(v any) bool

Check if a variable can be cast to an integer

func CheckIfStatement

func CheckIfStatement(ifStatement *model.RuntimeExpression, state *State) (bool, error)

func EvaluateString

func EvaluateString(str string, state *State, evaluationWrapper ...ExpressionWrapperFunc) (any, error)

The return value could be any value depending upon how it's parsed

func GenerateChildWorkflowName

func GenerateChildWorkflowName(prefix string, prefixes ...string) string

func LoadEnvvars

func LoadEnvvars(prefix string) map[string]any

LoadEnvvars load all environment variables that start with the prefix. Removes prefix for storage

func Ptr

func Ptr[T any](p T) *T

Ptr returns a pointer to p.

func SliceEvery

func SliceEvery[T any](items []T, predicate func(T) bool) bool

Functionally equivalent to JS's Array.prorotype.every function @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every

func SlicesEqual

func SlicesEqual[T comparable](s []T, v T) bool

Ensures that all slices are equal to the given value

func ToDuration

func ToDuration(v *model.Duration) (duration time.Duration)

Convert the Serverless Workflow duration into a time Duration

func TraverseAndEvaluateObj

func TraverseAndEvaluateObj(
	runtimeExpr *model.ObjectOrRuntimeExpr,
	state *State,
	evaluationWrapper ...ExpressionWrapperFunc,
) (map[string]any, error)

Types

type CancellableFuture

type CancellableFuture struct {
	Cancel  workflow.CancelFunc
	Context workflow.Context
	Future  workflow.ChildWorkflowFuture
}

type CancellableFutures

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

func (*CancellableFutures) Add

func (c *CancellableFutures) Add(key string, future CancellableFuture)

func (*CancellableFutures) CancelOthers

func (c *CancellableFutures) CancelOthers(passedContext workflow.Context)

func (*CancellableFutures) Length

func (c *CancellableFutures) Length() int

func (*CancellableFutures) List

type ExpressionWrapperFunc

type ExpressionWrapperFunc func(func() (any, error)) (any, error)

type State

type State struct {
	CANStartFrom *string        `json:"canStartFrom,omitempty"` // Continue-as-new from here
	Data         map[string]any `json:"data"`                   // Data stored along the way
	Env          map[string]any `json:"env"`                    // Available environment variables
	Input        any            `json:"input,omitempty"`        // The input given by the caller
	Output       map[string]any `json:"output"`                 // What will be output to the caller
}

func NewState

func NewState() *State

func (*State) AddActivityInfo

func (s *State) AddActivityInfo(ctx context.Context) *State

func (*State) AddData

func (s *State) AddData(data map[string]any) *State

func (*State) AddOutput

func (s *State) AddOutput(task model.Task, output any) *State

func (*State) AddWorkflowInfo

func (s *State) AddWorkflowInfo(ctx workflow.Context) *State

func (*State) ClearOutput

func (s *State) ClearOutput() *State

func (*State) Clone

func (s *State) Clone() *State

func (*State) GetAsMap

func (s *State) GetAsMap() map[string]any

Returns the state as a map. This can be used for

type ValidationErrors

type ValidationErrors struct {
	Key     string
	Message string
}

type Validator

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

func NewValidator

func NewValidator() (*Validator, error)

func (*Validator) ValidateStruct

func (v *Validator) ValidateStruct(data any) ([]ValidationErrors, error)

Jump to

Keyboard shortcuts

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