Help us shape the future of Go! Take the 2026 Go Developer Survey

blueprint

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package blueprint turns blueprints into flows and flows into blueprints.

A blueprint (design §4.8) is a flow body with declared parameters. Request and subflow references in its nodes may be {param: name}; the other parameters (string, int, bool) become inputs of the flow made from it. Using a blueprint copies it into an ordinary flow; nothing links the flow back to the blueprint.

Everything here is pure: references are looked up through a Resolver the caller provides and ids come from a function the caller provides.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoName = errors.New("a blueprint needs a name")

ErrNoName is returned by FromFlow for an empty blueprint name.

Functions

func Check

func Check(bp model.Blueprint) diag.List

Check validates a blueprint's own structure: parameter names and types, that every {param: x} names a declared parameter of the right type, and that reference parameters are used. The flow body is validated as an ordinary flow once the blueprint has been used.

func Default

func Default() model.Blueprint

Default is the blueprint new requests are seeded with. Its nodes become the request's inline post hooks, which see the response: they write its status to the run log and fail the request unless the status is 2xx. Redirects need no node: the engine follows them up to http.max_redirects and fails the request beyond it.

func DefaultAsync

func DefaultAsync() model.Blueprint

DefaultAsync is the post hook new async requests are seeded with. An async request has no status, so it logs the outcome and the number of messages received, and fails unless the run ended well.

func DefaultAsyncPre

func DefaultAsyncPre() model.Blueprint

DefaultAsyncPre is the pre hook new async requests are seeded with: it writes what is about to be sent to the run log.

func DefaultDataset

func DefaultDataset() model.Blueprint

DefaultDataset is the post hook new dataset requests are seeded with. A query has no HTTP status, so it logs the outcome and how many rows came back, and fails unless the query ran.

func DefaultGRPC

func DefaultGRPC() model.Blueprint

DefaultGRPC is the post hook new gRPC requests are seeded with. A gRPC call has a status code, not an HTTP status, so it logs the code and fails unless it is OK.

func DefaultGRPCPre

func DefaultGRPCPre() model.Blueprint

DefaultGRPCPre is the pre hook new gRPC requests are seeded with: it writes the call about to be made to the run log.

func FromFlow

func FromFlow(f model.Flow, newID func() model.ID, name string) (model.Blueprint, error)

FromFlow makes a blueprint from an existing flow: every distinct request or subflow reference in the same collection becomes a reference parameter whose default is the original target, and every input becomes a string parameter with its default. References into other collections stay as they are, since a parameter could not say which collection to look in. Using the result with its defaults rebuilds the original flow.

func Instantiate

func Instantiate(bp model.Blueprint, in Input) (model.Flow, diag.List)

Instantiate makes an ordinary flow from bp. Every problem found is reported (FLW-BP-005) and then no flow is returned.

Types

type Input

type Input struct {
	Values  map[string]string // parameter name → value; defaults fill the gaps
	Resolve Resolver
	NewID   func() model.ID
	Path    string // of the new flow, relative to flows/
	Name    string // of the new flow
}

Input is everything Instantiate needs besides the blueprint.

type Resolver

type Resolver interface {
	Request(value string) (model.Ref, error)
	Flow(value string) (model.Ref, error)
}

Resolver turns the text a user gave for a request-ref or flow-ref parameter (an id or a path) into a reference. The error says why it did not resolve and is shown to the user.

Jump to

Keyboard shortcuts

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