runtime

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args map[string]any

Args represents evaluated arguments passed to a Go step from an HCL manifest.

func (Args) Bind

func (a Args) Bind(dst any) error

Bind marshals and unmarshals arguments directly into a destination struct.

func (Args) Get

func (a Args) Get[T any](key string) (T, bool)

Get retrieves the argument at key and converts it to type T. Returns (zero, false) if the key is missing, null, or incompatible.

Example:

lat, ok := step.Args.Get[float64]("latitude")
role, ok := step.Args.Get[string]("role")
meta, ok := step.Args.Get[map[string]any]("metadata")

func (Args) GetOr

func (a Args) GetOr[T any](key string, fallback T) T

GetOr is like Get but returns a fallback if key is missing or null.

port := step.Args.GetOr("port", 8080)          // Inferred as int
host := step.Args.GetOr("host", "localhost")   // Inferred as string
priority := step.Args.GetOr("priority", false) // Inferred as bool
ratio := step.Args.GetOr("ratio", 0.95)        // Inferred as float64

func (Args) Has

func (a Args) Has(key string) bool

Has reports whether key exists in the arguments map and is not nil.

func (Args) Slice

func (a Args) Slice[T any](key string) []T

Slice retrieves an array of type T at key, safely coercing dynamic []any slices.

Example:

tags := step.Args.Slice[string]("tags")
ids  := step.Args.Slice[int]("user_ids")

type ExecutionContext

type ExecutionContext struct {
	Request        *RequestState         `json:"request"`
	Steps          map[string]StepResult `json:"steps"`
	TimestampEpoch int64                 `json:"timestamp_epoch"`
	IngressTime    time.Time             `json:"-"`
	Server         manifest.Server       `json:"-"`
	RawRequest     *http.Request         `json:"-"`
	// contains filtered or unexported fields
}

ExecutionContext encapsulates the runtime state for a single HTTP request pipeline execution.

func NewExecutionContext

func NewExecutionContext(w http.ResponseWriter, r *http.Request, opts ...ExecutionContextOption) (*ExecutionContext, error)

NewExecutionContext parses the incoming HTTP request, enforces body limits, and initializes state.

func (*ExecutionContext) Context

func (e *ExecutionContext) Context() context.Context

Context returns the underlying standard Go request context.

func (*ExecutionContext) GetStepResult

func (e *ExecutionContext) GetStepResult(stepName string) (StepResult, bool)

GetStepResult safely retrieves prior step output (concurrent-safe).

func (*ExecutionContext) NewStep

func (e *ExecutionContext) NewStep(name string, args Args) *Step

NewStep creates an isolated, thread-safe Step invocation referencing this ExecutionContext.

func (*ExecutionContext) SetStepResult

func (e *ExecutionContext) SetStepResult(stepName string, result StepResult)

SetStepResult safely records the output of a step (concurrent-safe for parallel execution).

func (*ExecutionContext) SnapshotSteps

func (e *ExecutionContext) SnapshotSteps() map[string]StepResult

SnapshotSteps returns a shallow copy of all step results recorded so far. Use this when passing steps to the HCL evaluation engine to prevent concurrent map read/write panics.

func (*ExecutionContext) WithContext

func (e *ExecutionContext) WithContext(ctx context.Context) *ExecutionContext

WithContext returns a shallow copy of ExecutionContext with an updated standard library context.

type ExecutionContextOption

type ExecutionContextOption func(*executionContextConfig)

ExecutionContextOption configures optional behavior during context creation.

func WithPathParams

func WithPathParams(paramNames []string) ExecutionContextOption

WithPathParams configures route parameter names to extract from the request.

func WithServer

func WithServer(server manifest.Server) ExecutionContextOption

WithServer attaches the resolved server configuration to the execution context.

type RequestState

type RequestState struct {
	Method  string            `json:"method"`
	Path    map[string]string `json:"path"`
	Query   map[string]string `json:"query"`
	Headers map[string]string `json:"headers"`
	Body    any               `json:"body"`
}

RequestState represents normalized HTTP request metadata extracted at runtime.

func (*RequestState) Header

func (r *RequestState) Header(key string) string

Header returns the header value for key (case-insensitive).

func (*RequestState) PathParam

func (r *RequestState) PathParam(key string, fallback ...string) string

PathParam returns the route path parameter value, or fallback if absent.

func (*RequestState) QueryParam

func (r *RequestState) QueryParam(key string, fallback ...string) string

QueryParam returns the query parameter value, or fallback if absent.

type Step

type Step struct {
	*ExecutionContext
	Name string `json:"name"`
	Args Args   `json:"args"`
}

Step encapsulates the invocation state and arguments for a single Go step.

func (*Step) Problem

func (s *Step) Problem(status int, detail string) problem.Problem

Problem constructs an RFC 9457 Problem bound to this step's execution context.

type StepHandler

type StepHandler func(ctx context.Context, step *Step) (any, error)

StepHandler defines the signature for custom native Go step callbacks.

type StepResult

type StepResult = map[string]any

StepResult represents arbitrary step-specific outputs.

Jump to

Keyboard shortcuts

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