utils

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 20 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, ctx any, state *State, evaluationWrapper ...ExpressionWrapperFunc) (any, error)

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

func FilePrepender added in v0.6.1

func FilePrepender(filename string) string

func GenerateChildWorkflowName

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

func LinkHandler added in v0.6.1

func LinkHandler(name 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 SanitizeForMDX added in v0.6.1

func SanitizeForMDX(path string) error

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 ToType added in v0.4.0

func ToType[T any](m any, result T) error

ToType this works in a similar way to mapstructure.Decode, but with JSON. This is because many of the Serverless Workflow types have custom marshal/unmarshal JSON functions.

func TraverseAndEvaluateObj

func TraverseAndEvaluateObj(
	runtimeExpr *model.ObjectOrRuntimeExpr,
	ctx any,
	state *State,
	evaluationWrapper ...ExpressionWrapperFunc,
) (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
	Context      any            `json:"context"`                // Output data exported to later tasks output
	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       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) 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.

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