Documentation
¶
Overview ¶
Package runtime manages request-scoped execution state, step outputs, and context lifecycles for pipeline runs.
Index ¶
- type Args
- type ExecutionContext
- func (e *ExecutionContext) Context() context.Context
- func (e *ExecutionContext) GetStepResult(stepName string) (StepResult, bool)
- func (e *ExecutionContext) NewStep(name string, args Args) *Step
- func (e *ExecutionContext) SetStepResult(stepName string, result StepResult)
- func (e *ExecutionContext) SnapshotSteps() map[string]StepResult
- func (e *ExecutionContext) WithContext(ctx context.Context) *ExecutionContext
- type ExecutionContextOption
- type RequestState
- type Step
- type StepHandler
- type StepResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Args ¶
Args represents evaluated arguments passed to a Go step from an HCL manifest.
func (Args) Get ¶
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 ¶
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
type ExecutionContext ¶
type ExecutionContext struct {
Request *RequestState `json:"request"`
Steps map[string]StepResult `json:"steps"`
TimestampEpoch int64 `json:"timestamp_epoch"`
IngressTime time.Time `json:"-"`
MaxBodySize int64 `json:"-"`
ProblemTypePrefix string `json:"-"`
RawRequest *http.Request `json:"-"`
// contains filtered or unexported fields
}
ExecutionContext encapsulates the state, context, and accumulated step outputs for a single request.
func NewExecutionContext ¶
func NewExecutionContext(w http.ResponseWriter, r *http.Request, opts ...ExecutionContextOption) (*ExecutionContext, error)
NewExecutionContext parses the incoming HTTP request, applies size constraints, and initializes pipeline state.
func (*ExecutionContext) Context ¶
func (e *ExecutionContext) Context() context.Context
Context returns the underlying standard library request context.
func (*ExecutionContext) GetStepResult ¶
func (e *ExecutionContext) GetStepResult(stepName string) (StepResult, bool)
GetStepResult retrieves the outputs of a previously executed step.
func (*ExecutionContext) NewStep ¶
func (e *ExecutionContext) NewStep(name string, args Args) *Step
NewStep creates an execution handle for a named step with evaluated arguments.
func (*ExecutionContext) SetStepResult ¶
func (e *ExecutionContext) SetStepResult(stepName string, result StepResult)
SetStepResult stores the exported outputs of a completed step.
func (*ExecutionContext) SnapshotSteps ¶
func (e *ExecutionContext) SnapshotSteps() map[string]StepResult
SnapshotSteps returns a shallow copy of all step outputs recorded up to this point.
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 when initializing an ExecutionContext.
func WithMaxBodySize ¶ added in v0.1.3
func WithMaxBodySize(maxBytes int64) ExecutionContextOption
WithMaxBodySize enforces an upper byte limit on the incoming HTTP request body.
func WithPathParams ¶
func WithPathParams(paramNames []string) ExecutionContextOption
WithPathParams configures the route path parameter names to extract from the request.
func WithProblemTypePrefix ¶ added in v0.1.3
func WithProblemTypePrefix(prefix string) ExecutionContextOption
WithProblemTypePrefix sets the base URI prefix used when deriving RFC 9457 problem error types.
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 holds normalized, read-only metadata extracted from an incoming HTTP request.
func (*RequestState) Header ¶
func (r *RequestState) Header(key string) string
Header returns the case-insensitive HTTP request header for key.
func (*RequestState) PathParam ¶
func (r *RequestState) PathParam(key string, fallback ...string) string
PathParam returns the route path parameter for key, or fallback if absent.
func (*RequestState) QueryParam ¶
func (r *RequestState) QueryParam(key string, fallback ...string) string
QueryParam returns the URL query parameter for key, or fallback if absent.
type Step ¶
type Step struct {
*ExecutionContext
Name string `json:"name"`
Args Args `json:"args"`
}
Step wraps ExecutionContext with step-specific metadata and evaluated arguments for a Go step handler.
type StepHandler ¶
StepHandler defines the signature for custom native Go step callbacks.
type StepResult ¶
StepResult represents the exported outputs of a completed pipeline step.