engine

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine coordinates routing, connection pools, and pipeline execution.

func New

func New(options Options) (*Engine, error)

New initializes an Engine by loading manifests and lowering them into a service definition.

func (*Engine) Close

func (e *Engine) Close() error

Close closes all active database connection pools.

func (*Engine) Handler

func (e *Engine) Handler() http.Handler

Handler returns the HTTP handler for the engine.

func (*Engine) RegisterStep

func (e *Engine) RegisterStep(name string, handler runtime.StepHandler) error

RegisterStep registers a native Go handler callback on the engine.

func (*Engine) Server

func (e *Engine) Server() service.Server

Server returns a copy of the resolved server transport configuration.

func (*Engine) Service added in v0.1.3

func (e *Engine) Service() *service.Definition

Service returns a copy of the active service definition.

type ErrorResponder added in v0.1.3

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

ErrorResponder centralizes RFC 9457 error formatting and response serialization.

func NewErrorResponder added in v0.1.3

func NewErrorResponder(p service.Problem, h problem.Handler, logger *slog.Logger) *ErrorResponder

NewErrorResponder initializes an error responder with the given problem configuration.

func (*ErrorResponder) Respond added in v0.1.3

func (r *ErrorResponder) Respond(w http.ResponseWriter, req *http.Request, err error)

Respond formats any error into an RFC 9457 Problem Details payload and sends it to the client.

type GoStep added in v0.1.3

type GoStep struct {
	Name     string
	Use      string
	Args     hcl.Expression
	Registry *StepRegistry
}

GoStep executes a registered native Go callback function.

func (*GoStep) Run added in v0.1.3

Run implements Step.Run.

type Options added in v0.1.3

type Options struct {
	// ConfigPath is a file or directory path containing .hcl manifests.
	ConfigPath string

	// StrictTyping enforces request schema validation on all endpoints.
	StrictTyping bool

	// ProblemHandler customizes RFC 9457 error serialization. If nil, defaults are used.
	ProblemHandler problem.Handler

	// Logger receives operational engine logs. If nil, logs are discarded.
	Logger *slog.Logger
}

Options defines configuration parameters for initializing the engine.

type Pipeline added in v0.1.3

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

Pipeline coordinates sequential step execution for an endpoint.

func NewPipeline added in v0.1.3

func NewPipeline(steps ...Step) *Pipeline

NewPipeline creates a new pipeline from an ordered slice of Steps.

func (*Pipeline) Execute added in v0.1.3

func (p *Pipeline) Execute(execCtx *runtime.ExecutionContext, w http.ResponseWriter) error

Execute runs configured steps in order until completion or pipeline termination.

type RespondStep added in v0.1.3

type RespondStep struct {
	Condition hcl.Expression
	Status    hcl.Expression
	Headers   hcl.Expression
	Body      hcl.Expression
}

RespondStep serializes HTTP headers, status code, and payload.

func (*RespondStep) Run added in v0.1.3

Run implements Step.Run.

type SQLStep added in v0.1.3

type SQLStep struct {
	Name    string
	Pool    *sqldb.Pool
	Query   string
	Args    hcl.Expression
	Catches []service.SQLCatch
}

SQLStep executes a database query or mutation with constraint catch blocks.

func (*SQLStep) Run added in v0.1.3

Run implements Step.Run.

type StarlarkStep added in v0.1.3

type StarlarkStep struct {
	Name   string
	Source string
}

StarlarkStep executes a sandboxed Starlark script.

func (*StarlarkStep) Run added in v0.1.3

Run implements Step.Run.

type Step added in v0.1.3

type Step interface {
	Run(execCtx *runtime.ExecutionContext, w http.ResponseWriter) (StepResult, error)
}

Step defines the execution contract for an individual pipeline step.

type StepRegistry added in v0.1.3

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

StepRegistry provides thread-safe registration and resolution of native Go step handlers.

func NewStepRegistry added in v0.1.3

func NewStepRegistry() *StepRegistry

NewStepRegistry initializes an empty step registry.

func (*StepRegistry) Get added in v0.1.3

func (r *StepRegistry) Get(name string) (runtime.StepHandler, bool)

Get safely retrieves a registered callback by name.

func (*StepRegistry) Register added in v0.1.3

func (r *StepRegistry) Register(name string, handler runtime.StepHandler) error

Register stores a named callback in the registry. It fails if the name is already in use.

type StepResult added in v0.1.3

type StepResult struct {
	// Terminated indicates whether the step sent an HTTP response and subsequent steps should be skipped.
	Terminated bool
}

StepResult represents the outcome of executing a pipeline step.

Jump to

Keyboard shortcuts

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