recipe

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSchemaString

func GenerateSchemaString() (string, error)

func PrintSchema

func PrintSchema()

func Validate

func Validate(recipex string) error

Types

type ActivityExecution

type ActivityExecution struct {
	Name      string // Activity name from YAML definition
	Status    string // Use string for flexibility
	StartTime time.Time
	EndTime   time.Time
	Duration  *time.Duration
	Result    map[string]interface{}
	Error     string
	Attempt   int

	ActivityID   string
	ActivityType string
}

ActivityExecution represents the execution state of an activity within a job

type ActivityStatus

type ActivityStatus string

ActivityStatus represents the execution status of an activity

const (
	ActivityStatusPending   ActivityStatus = "pending"
	ActivityStatusRunning   ActivityStatus = "running"
	ActivityStatusCompleted ActivityStatus = "completed"
	ActivityStatusFailed    ActivityStatus = "failed"
	ActivityStatusSkipped   ActivityStatus = "skipped"
)

type BaseVisitor

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

BaseVisitor provides default pass-through implementations Embed this to only override specific node types you care about

func (*BaseVisitor) ShouldTraverseSequenceChildren

func (b *BaseVisitor) ShouldTraverseSequenceChildren(node *NodeSequence, path []string) bool

Control methods default to true (always traverse)

func (*BaseVisitor) ShouldTraverseStateChildren

func (b *BaseVisitor) ShouldTraverseStateChildren(node *NodeState, path []string) bool

func (*BaseVisitor) VisitNodeOp

func (b *BaseVisitor) VisitNodeOp(node *NodeOp, path []string) (Node, error)

Leaf nodes - just return unchanged

func (*BaseVisitor) VisitNodeSequence

func (b *BaseVisitor) VisitNodeSequence(node *NodeSequence, path []string) (Node, error)

Container nodes - must traverse children

func (*BaseVisitor) VisitNodeShared

func (b *BaseVisitor) VisitNodeShared(node *NodeShared, path []string) (Node, error)

func (*BaseVisitor) VisitNodeState

func (b *BaseVisitor) VisitNodeState(node *NodeState, path []string) (Node, error)

func (*BaseVisitor) VisitRecipe

func (b *BaseVisitor) VisitRecipe(recipe *Recipe) (Recipe, error)

func (*BaseVisitor) VisitRecipeOp

func (b *BaseVisitor) VisitRecipeOp(node *RecipeOp, path []string) (*RecipeOp, error)

Root recipe nodes

func (*BaseVisitor) VisitRecipeSequence

func (b *BaseVisitor) VisitRecipeSequence(node *RecipeSequence, path []string) (*RecipeSequence, error)

func (*BaseVisitor) VisitRecipeState

func (b *BaseVisitor) VisitRecipeState(node *RecipeState, path []string) (*RecipeState, error)

type Duration

type Duration time.Duration

Duration wraps time.Duration to provide custom YAML marshaling/unmarshaling It serializes to/from human-readable strings like "1s", "500ms", "2m"

func (Duration) JSONSchema

func (d Duration) JSONSchema() *jsonschema.Schema

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML converts Duration to a YAML string

func (Duration) String

func (d Duration) String() string

String implements the Stringer interface

func (Duration) ToDuration

func (d Duration) ToDuration() time.Duration

ToDuration converts to standard time.Duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML parses a YAML string into a Duration

type ExtensionFunctionImport

type ExtensionFunctionImport struct {
	Selector string            `yaml:"selector"`
	Include  []string          `yaml:"include,omitempty"`
	Rename   map[string]string `yaml:"rename,omitempty"`
}

type ExtensionImports

type ExtensionImports struct {
	Functions []ExtensionFunctionImport `yaml:"functions,omitempty"`
}

type HashComputer

type HashComputer struct{}

HashComputer computes canonical hashes for recipes

func NewHashComputer

func NewHashComputer() *HashComputer

NewHashComputer creates a new hash computer

func (*HashComputer) ComputeRecipeHash

func (h *HashComputer) ComputeRecipeHash(recipe *Recipe) string

ComputeRecipeHash computes a deterministic hash of recipe content

type InitialTransitions

type InitialTransitions []Transition

InitialTransitions represents the transition block used to choose the first state. YAML supports:

  • `initial: state_name` (shorthand)
  • `initial: {to: state_name, when: ...}`
  • `initial: [{to: state_a, when: ...}, ...]`

func InitialState

func InitialState(stateName string) InitialTransitions

InitialState returns the shorthand initial transition to a named state.

func (InitialTransitions) JSONSchema

func (InitialTransitions) JSONSchema() *jsonschema.Schema

func (InitialTransitions) MarshalYAML

func (i InitialTransitions) MarshalYAML() (interface{}, error)

func (InitialTransitions) ShortcutState

func (i InitialTransitions) ShortcutState() (string, bool)

func (InitialTransitions) Transitions

func (i InitialTransitions) Transitions() []Transition

func (*InitialTransitions) UnmarshalYAML

func (i *InitialTransitions) UnmarshalYAML(node *yamlv3.Node) error

type InputSchema

type InputSchema struct {
	Type        string      `yaml:"type,omitempty"`                                                // Type of the input (string, number, boolean, etc.)
	Description string      `yaml:"description,omitempty"`                                         // Description of the input
	Required    bool        `yaml:"required,omitempty"`                                            // Whether the input is required
	Default     interface{} `yaml:"default_value,omitempty" jsonschema:"oneof_type=string;number"` // Default value if not provided
}

InputSchema defines the schema for an input parameter

type Job

type Job struct {
	ID            string
	RecipeName    string
	RecipeVersion string
	Status        JobStatus
	StartTime     time.Time
	EndTime       *time.Time
	UpdateTime    time.Time
	Input         map[string]interface{}
	Output        map[string]interface{}
	Error         string

	// Optional fields
	Duration     *time.Duration
	Inputs       map[string]interface{} // alias for Input
	Outputs      map[string]interface{} // alias for Output
	Activities   []*ActivityExecution
	WorkflowType string

	ExecutionInfo *WorkflowExecutionInfo
}

Job represents an execution instance of a recipe

type JobFilter

type JobFilter struct {
	RecipeName string
	Status     *JobStatus
	StartTime  *time.Time
	EndTime    *time.Time
	Limit      int
}

JobFilter represents filter criteria for listing jobs

type JobStatus

type JobStatus string

JobStatus represents the execution status of a job

const (
	JobStatusUnknown    JobStatus = "unknown"
	JobStatusRunning    JobStatus = "running"
	JobStatusCompleted  JobStatus = "completed"
	JobStatusFailed     JobStatus = "failed"
	JobStatusCanceled   JobStatus = "canceled"
	JobStatusTerminated JobStatus = "terminated"
)

type Node

type Node struct {
	NodeImpl
}

func (Node) GetMetadata

func (n Node) GetMetadata() NodeMetadata

func (Node) JSONSchema

func (Node) JSONSchema() *jsonschema.Schema

func (Node) MarshalYAML

func (n Node) MarshalYAML() (interface{}, error)

MarshalYAML ensures Node marshals to the same shape expected by UnmarshalYAML by delegating directly to the underlying concrete implementation.

func (*Node) UnmarshalYAML

func (n *Node) UnmarshalYAML(node *yamlv3.Node) error

type NodeImpl

type NodeImpl interface {
	GetMetadata() NodeMetadata
	// contains filtered or unexported methods
}

type NodeList

type NodeList []Node

type NodeMetadata

type NodeMetadata struct {
	ID        string                 `yaml:"id,omitempty"`
	Desc      string                 `yaml:"desc,omitempty"`
	Const     bool                   `yaml:"const,omitempty"`
	Timeout   Duration               `yaml:"timeout,omitempty"`
	Retry     *RetryPolicy           `yaml:"retry,omitempty"`
	Inputs    map[string]interface{} `yaml:"inputs,omitempty"`
	Vars      map[string]interface{} `yaml:"vars,omitempty"`
	Artifacts map[string]interface{} `yaml:"artifacts,omitempty"`
	When      cel.CELExpr            `yaml:"when,omitempty"` // Conditional execution
}

type NodeOp

type NodeOp struct {
	NodeMetadata `yaml:",inline"`
	OpData       `yaml:",inline"`
}

func (*NodeOp) GetMetadata

func (n *NodeOp) GetMetadata() NodeMetadata

func (NodeOp) JSONSchema

func (NodeOp) JSONSchema() *jsonschema.Schema

type NodeSequence

type NodeSequence struct {
	NodeMetadata `yaml:",inline"`
	SequenceData `yaml:",inline"`
}

func (*NodeSequence) GetMetadata

func (n *NodeSequence) GetMetadata() NodeMetadata

type NodeShared

type NodeShared struct {
	Shared string `yaml:"shared"`
}

func (*NodeShared) GetMetadata

func (n *NodeShared) GetMetadata() NodeMetadata

type NodeState

type NodeState struct {
	NodeMetadata     `yaml:",inline"`
	StateMachineData `yaml:",inline"`
}

func (*NodeState) GetMetadata

func (n *NodeState) GetMetadata() NodeMetadata

type NodeVisitor

type NodeVisitor interface {
	// Root node visitors - return (replacement, error)
	VisitRecipe(recipe *Recipe) (Recipe, error)
	VisitRecipeOp(node *RecipeOp, path []string) (*RecipeOp, error)
	VisitRecipeSequence(node *RecipeSequence, path []string) (*RecipeSequence, error)
	VisitRecipeState(node *RecipeState, path []string) (*RecipeState, error)

	// Intermediate node visitors - return (replacement, error)
	VisitNodeOp(node *NodeOp, path []string) (Node, error)
	VisitNodeShared(node *NodeShared, path []string) (Node, error)
	VisitNodeSequence(node *NodeSequence, path []string) (Node, error)
	VisitNodeState(node *NodeState, path []string) (Node, error)

	// Control whether to traverse children of container nodes
	ShouldTraverseSequenceChildren(node *NodeSequence, path []string) bool
	ShouldTraverseStateChildren(node *NodeState, path []string) bool
}

NodeVisitor defines the interface for visiting and transforming recipe node trees

type NodeWalker

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

NodeWalker orchestrates the traversal of a recipe tree

func NewNodeWalker

func NewNodeWalker(visitor NodeVisitor) *NodeWalker

NewNodeWalker creates a new walker with the given visitor

func (*NodeWalker) Walk

func (w *NodeWalker) Walk(recipe Recipe) (Recipe, error)

Walk traverses the entire recipe tree

func (*NodeWalker) WalkNode

func (w *NodeWalker) WalkNode(node Node, path []string) (Node, error)

WalkNode recursively processes intermediate nodes

type OpData

type OpData struct {
	Op string `yaml:"op"`
}

type Recipe

type Recipe struct {
	RecipeImpl
}

func LoadRecipeFromReader

func LoadRecipeFromReader(r io.Reader) (*Recipe, error)

func LoadRecipeFromString

func LoadRecipeFromString(data []byte) (*Recipe, error)

func (Recipe) GetMetdata

func (r Recipe) GetMetdata() RecipeMetadata

func (Recipe) JSONSchema

func (Recipe) JSONSchema() *jsonschema.Schema

func (*Recipe) MarshalYAML

func (n *Recipe) MarshalYAML() (interface{}, error)

func (*Recipe) UnmarshalYAML

func (n *Recipe) UnmarshalYAML(node *yamlv3.Node) error

type RecipeFile

type RecipeFile struct {
	// Core identity
	ID          string
	Version     string
	Description string

	// File paths
	BasePath string // Directory containing the recipe

	// Content
	Recipe Recipe

	// Metadata
	Hash         string // Canonical hash of recipe content
	LastModified time.Time
}

Recipe represents a discovered recipe with its metadata

type RecipeImpl

type RecipeImpl interface {
	GetMetadata() RecipeMetadata
	// contains filtered or unexported methods
}

type RecipeManifest

type RecipeManifest struct {
	Recipe struct {
		Name        string `yaml:"name"`
		Version     string `yaml:"version"`
		Description string `yaml:"description"`
		Files       struct {
			Workflow   string `yaml:"workflow"`
			Activities string `yaml:"activities"`
			Agents     string `yaml:"agents"`
		} `yaml:"files"`
	} `yaml:"recipe"`
}

RecipeManifest represents the recipe.yaml structure

type RecipeMetadata

type RecipeMetadata struct {
	Version      string `yaml:"version"`
	NodeMetadata `yaml:",inline"`
	Defs         map[string]Node        `yaml:"defs,omitempty"`         // Shared node definitions
	InputSchema  map[string]InputSchema `yaml:"input_schema,omitempty"` // Optional schema for inputs
	Extensions   ExtensionImports       `yaml:"extensions,omitempty"`
}

func (RecipeMetadata) ValidateInputShapeAndFillDefaults

func (n RecipeMetadata) ValidateInputShapeAndFillDefaults(data map[string]interface{}) (map[string]interface{}, error)

type RecipeOp

type RecipeOp struct {
	RecipeMetadata `yaml:",inline" refer:"true"`
	OpData         `yaml:",inline" refer:"true"`
}

func (*RecipeOp) GetMetadata

func (r *RecipeOp) GetMetadata() RecipeMetadata

type RecipeProvider

type RecipeProvider interface {
	GetRecipe(name string) (*Recipe, error)
}

type RecipeSequence

type RecipeSequence struct {
	RecipeMetadata `yaml:",inline" refer:"true"`
	SequenceData   `yaml:",inline" refer:"true"`
}

func (*RecipeSequence) GetMetadata

func (r *RecipeSequence) GetMetadata() RecipeMetadata

type RecipeState

type RecipeState struct {
	RecipeMetadata   `yaml:",inline" refer:"true"`
	StateMachineData `yaml:",inline" refer:"true"`
}

func (*RecipeState) GetMetadata

func (r *RecipeState) GetMetadata() RecipeMetadata

type RetryPolicy

type RetryPolicy = swf.RetryPolicy

type SequenceData

type SequenceData struct {
	Sequence NodeList               `yaml:"sequence,omitempty"`
	Outputs  map[string]interface{} `yaml:"outputs,omitempty"`
}

type SharedNodeResolver

type SharedNodeResolver struct {
	BaseVisitor // Embed to get default implementations
	// contains filtered or unexported fields
}

SharedNodeResolver resolves SharedNode references to their definitions

func NewSharedNodeResolver

func NewSharedNodeResolver(defs map[string]Node) *SharedNodeResolver

NewSharedNodeResolver creates a resolver with the given definitions

func (*SharedNodeResolver) VisitNodeShared

func (r *SharedNodeResolver) VisitNodeShared(node *NodeShared, path []string) (Node, error)

VisitNodeShared resolves shared node references

type SingleStateMetadata

type SingleStateMetadata struct {
	Transitions []Transition `yaml:"transitions,omitempty" json:"transitions,omitempty"`
}

type State

type State struct {
	Node                `yaml:",inline"`
	SingleStateMetadata `yaml:",inline"`
}

State represents a state in a state machine A state is a node plus transition information

func (State) MarshalYAML

func (s State) MarshalYAML() (interface{}, error)

MarshalYAML customizes encoding so state-only fields (like transitions) are preserved alongside the inline node fields.

func (*State) UnmarshalYAML

func (s *State) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML customizes decoding so state-only fields (like transitions) don't get swallowed by the inline Node's UnmarshalYAML implementation.

type StateMachineData

type StateMachineData struct {
	States  *StateMap              `yaml:"state,omitempty"`
	Outputs map[string]interface{} `yaml:"outputs,omitempty"`
}

type StateMap

type StateMap struct {
	Initial InitialTransitions `yaml:"initial" validate:"required"` // State selector transitions (string is supported as shorthand)
	States  map[string]State   `yaml:"states"`                      // Inline the states
}

StateMap represents a state machine configuration

type Transition

type Transition struct {
	To      string                 `yaml:"to"`
	When    cel.CELExpr            `yaml:"when,omitempty"` // CEL expression
	Payload map[string]interface{} `yaml:"payload,omitempty"`
}

Transition represents a state transition

func (Transition) JSONSchema

func (Transition) JSONSchema() *jsonschema.Schema

func (*Transition) UnmarshalYAML

func (t *Transition) UnmarshalYAML(node *yamlv3.Node) error

type WorkerStatus

type WorkerStatus string

WorkerStatus represents the status of a recipe's worker

const (
	WorkerStatusRunning  WorkerStatus = "running"
	WorkerStatusStopped  WorkerStatus = "stopped"
	WorkerStatusFailed   WorkerStatus = "failed"
	WorkerStatusStarting WorkerStatus = "starting"
)

type WorkflowExecutionInfo

type WorkflowExecutionInfo struct {
	JobId string
}

WorkflowExecutionInfo contains job info

Jump to

Keyboard shortcuts

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