block

package
v0.1.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BashExecutor

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

BashExecutor executes Bash script blocks

func NewBashExecutor

func NewBashExecutor(cacheDir string) (*BashExecutor, error)

NewBashExecutor creates a new Bash script executor

func (*BashExecutor) Execute

func (e *BashExecutor) Execute(execCtx *execcontext.ExecutionContext, block *Block, inputs map[string]interface{}) (interface{}, error)

Execute runs a Bash script block

func (*BashExecutor) ExecuteRaw

func (e *BashExecutor) ExecuteRaw(execCtx *execcontext.ExecutionContext, block *Block, inputJSON json.RawMessage) (interface{}, error)

func (*BashExecutor) Validate

func (e *BashExecutor) Validate(block *Block) error

Validate checks if the executor can handle the given block

type Block

type Block struct {
	Name        string                  `yaml:"name"`
	Metadata    map[string]interface{}  `yaml:"metadata,omitempty"`
	Path        string                  `yaml:"-"` // Filesystem path
	Runtime     RuntimeType             `yaml:"runtime"`
	Description string                  `yaml:"description,omitempty"`
	Inputs      map[string]InputSchema  `yaml:"inputs,omitempty"`
	Outputs     map[string]OutputSchema `yaml:"outputs,omitempty"`

	// Runtime-specific fields
	Workflow *ast.Workflow     `yaml:"workflow,omitempty"` // For native blocks
	Script   string            `yaml:"script,omitempty"`   // For go blocks
	Image    string            `yaml:"image,omitempty"`    // For docker blocks
	Command  []string          `yaml:"command,omitempty"`  // For docker blocks
	Env      map[string]string `yaml:"env,omitempty"`      // For docker blocks

	// Cached data
	ModTime      time.Time `yaml:"-"`
	CompiledPath string    `yaml:"-"` // For go blocks
}

Block represents a reusable workflow component

type DockerExecutor

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

DockerExecutor executes Docker blocks

func NewDockerExecutor

func NewDockerExecutor() *DockerExecutor

NewDockerExecutor creates a new Docker block executor

func (*DockerExecutor) Execute

func (e *DockerExecutor) Execute(execCtx *execcontext.ExecutionContext, block *Block, inputs map[string]interface{}) (interface{}, error)

Execute runs a Docker block

func (*DockerExecutor) Validate

func (e *DockerExecutor) Validate(block *Block) error

Validate checks if the executor can handle the given block

type ExecutionError

type ExecutionError struct {
	Message string                 `json:"message"`
	Code    string                 `json:"code,omitempty"`
	Details string                 `json:"details,omitempty"`
	Data    map[string]interface{} `json:"data,omitempty"`
}

ExecutionError represents an error from block execution

type ExecutionInput

type ExecutionInput struct {
	Inputs map[string]interface{} `json:"inputs"`
	Env    map[string]string      `json:"-"`
}

ExecutionInput represents the JSON input sent to blocks

type Executor

type Executor interface {
	// Execute runs a block with the given inputs
	Execute(execCtx *execcontext.ExecutionContext, block *Block, inputs map[string]interface{}) (interface{}, error)

	// Validate checks if the executor can handle the given block
	Validate(block *Block) error
}

Executor executes blocks

type ExecutorRegistry

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

ExecutorRegistry manages executors for different runtime types

func NewExecutorRegistry

func NewExecutorRegistry() *ExecutorRegistry

func (*ExecutorRegistry) Execute

func (r *ExecutorRegistry) Execute(execCtx *execcontext.ExecutionContext, block *Block, inputs map[string]interface{}) (interface{}, error)

Execute runs a block using the appropriate executor and validates the block

func (*ExecutorRegistry) Get

func (r *ExecutorRegistry) Get(runtime RuntimeType) (Executor, bool)

Get returns the executor for a runtime type

func (*ExecutorRegistry) Register

func (r *ExecutorRegistry) Register(runtime RuntimeType, executor Executor)

Register registers an executor for a runtime type

type FileLoader

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

FileLoader loads blocks from the filesystem

func NewFileLoader

func NewFileLoader() *FileLoader

NewFileLoader creates a new file-based block loader

func (*FileLoader) GetFromCache

func (l *FileLoader) GetFromCache(path string) (*Block, bool)

GetFromCache returns a cached block if available

func (*FileLoader) InvalidateCache

func (l *FileLoader) InvalidateCache(path string)

InvalidateCache removes a block from the cache

func (*FileLoader) Load

func (l *FileLoader) Load(ctx context.Context, path string) (*Block, error)

Load loads a block from the given path

type InputSchema

type InputSchema struct {
	Type        string      `yaml:"type"`
	Description string      `yaml:"description,omitempty"`
	Required    bool        `yaml:"required,omitempty"`
	Default     interface{} `yaml:"default,omitempty"`
	Enum        []string    `yaml:"enum,omitempty"`
	Items       interface{} `yaml:"items,omitempty"`      // For arrays
	Properties  interface{} `yaml:"properties,omitempty"` // For objects
}

InputSchema defines the schema for a block input parameter

type Loader

type Loader interface {
	// Load loads a block from the given path
	Load(ctx context.Context, path string) (*Block, error)

	// GetFromCache returns a cached block if available
	GetFromCache(path string) (*Block, bool)

	// InvalidateCache removes a block from the cache
	InvalidateCache(path string)
}

Loader loads blocks from the filesystem

type Manager

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

Manager manages block loading and execution

func NewManager

func NewManager(cacheDir string) (*Manager, error)

NewManager creates a new block manager

func (*Manager) ExecuteBlock

func (m *Manager) ExecuteBlock(execCtx *execcontext.ExecutionContext, blockPath string, inputs map[string]interface{}) (interface{}, error)

ExecuteBlock executes a block at the given path with the given inputs

func (*Manager) ExecuteRawBlock

func (m *Manager) ExecuteRawBlock(execCtx *execcontext.ExecutionContext, block *Block, inputs map[string]interface{}) (interface{}, error)

ExecuteRawBlock executes a block with the given inputs, it does not validate inputs

func (*Manager) GetBlockInfo

func (m *Manager) GetBlockInfo(ctx context.Context, path string) (*Block, error)

GetBlockInfo returns information about a block without executing it

func (*Manager) InvalidateCache

func (m *Manager) InvalidateCache(path string)

InvalidateCache invalidates the cache for a block

func (*Manager) LoadBlock

func (m *Manager) LoadBlock(ctx context.Context, path string) (*Block, error)

LoadBlock loads a block from the given path

type NativeExecutor

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

NativeExecutor executes native Lacquer blocks (YAML workflows)

func NewNativeExecutor

func NewNativeExecutor(engine WorkflowEngine) *NativeExecutor

NewNativeExecutor creates a new native block executor

func (*NativeExecutor) Execute

func (e *NativeExecutor) Execute(execCtx *execcontext.ExecutionContext, block *Block, inputs map[string]interface{}) (interface{}, error)

Execute runs a native block

func (*NativeExecutor) Validate

func (e *NativeExecutor) Validate(block *Block) error

Validate checks if the executor can handle the given block

type OutputSchema

type OutputSchema struct {
	Type        string `yaml:"type"`
	Description string `yaml:"description,omitempty"`
	From        string `yaml:"from,omitempty"` // For docker blocks reading from files
}

OutputSchema defines the schema for a block output parameter

type Registry

type Registry interface {
	// Register registers an executor for a runtime type
	Register(runtime RuntimeType, executor Executor)

	// Get returns the executor for a runtime type
	Get(runtime RuntimeType) (Executor, bool)
}

Registry manages block executors by runtime type

type RuntimeType

type RuntimeType string

RuntimeType defines the execution runtime for a block

const (
	RuntimeNative RuntimeType = "native"
	RuntimeDocker RuntimeType = "docker"
	RuntimeBash   RuntimeType = "bash"
)

type WorkflowEngine

type WorkflowEngine interface {
	Execute(execCtx *execcontext.ExecutionContext, workflow *ast.Workflow, inputs map[string]interface{}) (map[string]interface{}, error)
}

WorkflowEngine interface for workflow execution

Jump to

Keyboard shortcuts

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