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

model

package
v0.1.0-alpha.3 Latest Latest
Warning

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

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

Documentation

Overview

Package model defines Flow-I's domain types as plain data. It performs no I/O and holds no behaviour beyond small structural helpers; storage, validation and execution live in other packages.

Index

Constants

View Source
const (
	ProtocolWS    = "ws"
	ProtocolSSE   = "sse"
	ProtocolMQTT  = "mqtt"
	ProtocolKafka = "kafka"
	ProtocolAMQP  = "amqp"
	ProtocolNATS  = "nats"

	// Managed messaging and Redis (ADR 0019).
	ProtocolRedis      = "redis"
	ProtocolSQS        = "sqs"
	ProtocolSNS        = "sns"
	ProtocolServiceBus = "servicebus"
	ProtocolPubSub     = "pubsub"
)

The async protocols a request can speak.

View Source
const (
	AuthDefault  = "default"  // the provider's own credential lookup
	AuthExplicit = "explicit" // the credential bindings of the request
)

Values of the `auth` binding of the cloud protocols.

View Source
const (
	GRPCSchemePlaintext = "grpc"
	GRPCSchemeTLS       = "grpcs"
)

The URL schemes of a gRPC server.

View Source
const (
	AsyncSendOnly     = "send"
	AsyncReceiveOnly  = "receive"
	AsyncRequestReply = "request_reply"
)

The actions an Async version can have.

View Source
const ProtocolVerbGRPC = "GRPC"

ProtocolVerbGRPC is what a gRPC request shows where an HTTP request shows its method.

Variables

This section is empty.

Functions

func AsyncBindings

func AsyncBindings(p string) []string

AsyncBindings are the binding names protocol p understands.

func AsyncCredentials

func AsyncCredentials(p string) []string

AsyncCredentials are the binding names of protocol p that hold credentials.

func AsyncProtocols

func AsyncProtocols() []string

AsyncProtocols lists the protocols in catalogue order.

func AsyncSchemes

func AsyncSchemes(p string) []string

AsyncSchemes are the URL schemes a server of protocol p may use.

func CloudProtocol

func CloudProtocol(p string) bool

CloudProtocol reports whether p is a cloud service with an `auth` mode: the provider's default login, or the explicit credential bindings.

func DefaultEnvColour

func DefaultEnvColour(name string) string

DefaultEnvColour is the colour a new environment of that name starts with: red for a name that begins with "prod" (any case), since that is the environment where a slip costs the most.

func EnvColours

func EnvColours() []string

EnvColours are the colours an environment can be marked with.

func GRPCTarget

func GRPCTarget(server string) (hostport string, useTLS bool)

GRPCTarget is the host and port to dial and whether to use TLS. A scheme decides; a bare host:port is plaintext for the local machine (localhost, 127.0.0.1, ::1) and TLS for any other host.

func GRPCTargetURL

func GRPCTargetURL(server, method string) string

GRPCTargetURL is where a gRPC call goes, for display: the server with the scheme the call will use, then the method. A templated server is shown as written, since its scheme is only known when it runs.

func JoinURL

func JoinURL(server, channel string) string

JoinURL puts a channel after a server URL: "wss://h" and "events" give "wss://h/events"; an empty channel leaves the server alone.

func KnownProtocol

func KnownProtocol(p string) bool

KnownProtocol reports whether p is an async protocol.

func NormalizeServer

func NormalizeServer(protocol, server string) string

NormalizeServer writes out the scheme of a server that left it off: a NATS or Kafka server is often written as host:port, a Service Bus one as the namespace host. A templated server, one with a scheme and one of a protocol with several schemes are returned as given.

func ProtocolOfVerb

func ProtocolOfVerb(verb string) string

ProtocolOfVerb is the protocol a verb stands for, or "" when it is not one (an HTTP method).

func ProtocolVerb

func ProtocolVerb(protocol string) string

ProtocolVerb is the short upper-case name a protocol shows where an HTTP request shows its method: MQTT, WS, … and BUS for Service Bus.

func RedactedTarget

func RedactedTarget(target string) string

RedactedTarget hides the password of user:password@ in a URL-like target, for anything recorded or shown. A user name alone is left as it is.

func SplitMethod

func SplitMethod(m string) (service, method string, ok bool)

SplitMethod splits package.Service/Method into the service and method names. A leading slash (grpcurl's way of writing it) is allowed.

func TargetURL

func TargetURL(protocol, server, channel string) string

TargetURL is where an async request goes, for display and for the protocols that connect to a path: the server and channel joined. For SSE the channel names the event to keep, not a path, so the server alone is the URL.

Types

type Async

type Async struct {
	Protocol string // ws, sse, mqtt, kafka, amqp or nats
	Server   string // templated; e.g. mqtt://host:1883
	Channel  string // topic, subject, queue, or routing key
	Send     *AsyncSend
	Receive  *AsyncReceive
	// Binding is the protocol's own options (qos, key, exchange, …), in
	// file order; the allowed names depend on the protocol.
	Binding []KeyValue
}

Async is what an async request version does: it sends a message to a channel, receives messages from it, or both (request and reply).

func (Async) Action

func (a Async) Action() string

Action is send, receive or request_reply; "" when neither side is set.

type AsyncReceive

type AsyncReceive struct {
	Count   int
	Timeout time.Duration
	// Match, when set, is an expression a message must satisfy to count.
	Match string
}

AsyncReceive says which messages an async request waits for. Count 0 means 1 and Timeout 0 means 30s when it runs.

type AsyncSend

type AsyncSend struct {
	Body    Body
	Headers []KeyValue
}

AsyncSend is the message an async request sends.

type Blueprint

type Blueprint struct {
	Meta
	Path string
	// Phase says which hooks of a request the blueprint's nodes can be: "pre"
	// or "post"; empty means post. It does not matter to a blueprint used to
	// make a flow.
	Phase  string
	Params []Param
	Body   Flow
	File   string
}

Blueprint is a flow template with declared parameters (design §4.8). Body holds the flow's inputs, outputs, execution, run settings and nodes; its identity fields are unused. Using a blueprint makes an ordinary flow and leaves no link back. Path is relative to blueprints/ without the suffix.

type Body

type Body struct {
	JSON      string
	Text      string
	File      string
	Form      []KeyValue
	Multipart []Field
}

Body is a request body. At most one field is set.

type Branch

type Branch struct {
	ID    string
	Nodes []Node
}

Branch is one lane of a parallel node.

type Case

type Case struct {
	When  string
	Nodes []Node
}

Case is one arm of a condition node's switch.

type Collection

type Collection struct {
	Root         string
	Manifest     Manifest
	Folders      []Folder
	Environments []Environment
	Requests     []Request
	Flows        []Flow
	Blueprints   []Blueprint
}

Collection is everything loaded from one collection directory.

type Dependency

type Dependency struct {
	ID   ID
	Name string
	Repo string // optional clone URL shown when the dependency is not mounted
}

Dependency is another collection this one references.

type EnvVar

type EnvVar struct {
	Name   string
	Value  string
	Secret bool
}

EnvVar is one environment variable. When Secret is set, Value is empty: the value lives in the workspace vault.

type Environment

type Environment struct {
	Meta
	Vars []EnvVar
	File string
	// Colour marks the environment wherever it is chosen, so that one is not mistaken for another.
	// It is one of EnvColours(), or empty for the default; an unknown name is shown as the default.
	Colour string
	// Scope is the vault scope of this environment's secrets. Empty means
	// the owning collection; global environments carry the workspace scope.
	Scope ID
}

Environment is a named set of variables. Name defaults to the file stem.

type Execution

type Execution struct {
	MaxConcurrency int
	RateLimit      string
	HostRateLimits []KeyValue
	OnBranchError  string
}

Execution controls where concurrency is allowed to go. RateLimit applies to every host; HostRateLimits to the hosts they name.

type Extraction

type Extraction struct {
	Name   string
	From   string
	Path   string
	Header string
	Cookie string
	Regex  string
}

Extraction names a value taken from a response. From is one of body, header, cookie or status; the matching selector field is set.

type Field

type Field struct {
	Key   string
	Value any
}

Field is an ordered key with an arbitrary YAML value: string, bool, int64, float64, []any, []Field or nil.

type Flow

type Flow struct {
	Meta
	Path          string
	PreferVersion string
	Inputs        []Input
	Outputs       []KeyValue // name → template rendered when the flow ends (subflows)
	Execution     Execution
	Run           *RunTill
	Nodes         []Node
	File          string
}

Flow is a graph of nodes. Path is relative to flows/ without the .flow.yaml suffix.

type Folder

type Folder struct {
	Dir      string
	Settings Settings
	Hooks    Hooks
	// Order lists the names of the folder's entries (a request or flow without its
	// file suffix, or a sub-folder's name) in the order they are shown. Entries it
	// does not name follow, by name; a name that matches nothing is ignored.
	Order []string
	File  string
}

Folder holds the settings and hooks of one _folder.yaml. Dir is relative to the collection root and slash-separated, e.g. "requests/auth".

type GRPC

type GRPC struct {
	// Server is grpc://host:port (plaintext), grpcs://host:port (TLS) or a bare
	// host:port; templated, e.g. {{env.api}}.
	Server string
	// Method is package.Service/Method.
	Method string
	// Body is the request message, as JSON (or text holding JSON).
	Body Body
	// Proto lists .proto files, relative to the collection. Empty: the schema
	// is asked of the server by reflection.
	Proto []string
	// Import lists the roots .proto imports are resolved against, relative to
	// the collection.
	Import []string
	// Receive says which messages of a server stream to keep; unused for a
	// unary call. Count 0 means 1 and Timeout 0 means 30s when it runs.
	Receive *AsyncReceive
}

GRPC is what a gRPC request version does: it calls one method of a service with a JSON message and reads the response (one message, or a stream).

type HookControl

type HookControl struct {
	Mode string
	Skip []string
}

HookControl decides which API hooks a request node runs. Mode is "all" (default) or "none"; Skip lists "pre" and/or "post".

type HookStep

type HookStep struct {
	Flow   *Ref
	Inline []Node
}

HookStep is one pre or post hook: a reusable flow or inline nodes. Exactly one of Flow and Inline is set.

type Hooks

type Hooks struct {
	Pre  []HookStep
	Post []HookStep
}

Hooks are the pre and post steps attached to an API at some scope.

type ID

type ID string

ID is a ULID in canonical upper-case form.

type Input

type Input struct {
	Name    string
	Default string
}

Input is a declared flow input with an optional default template.

type KeyValue

type KeyValue struct {
	Key   string
	Value string
	// Description says what the entry is for; only requests keep it (query,
	// headers, variables).
	Description string
}

KeyValue is an ordered string pair (headers, query parameters, inputs).

type Layout

type Layout struct {
	Flow      ID
	Nodes     map[string]Point // manual positions by node id
	Collapsed []string         // collapsed action strips, by first node id
	File      string
}

Layout is a flow's *.layout.yaml: canvas positions only, kept apart from the flow so moving nodes never changes the flow file (design §4.7).

type Manifest

type Manifest struct {
	Format int
	Meta
	DependsOn []Dependency
	Settings  Settings
	Hooks     Hooks
	File      string
}

Manifest is the content of a collection's flowi.yaml.

type Meta

type Meta struct {
	ID          ID
	Name        string
	Description string
}

Meta is the identity shared by every entity.

type Mount

type Mount struct {
	ID   ID
	Path string // as the user gave it; may start with "~"
}

Mount is a collection loaded into a workspace from a directory.

type Node

type Node struct {
	ID          string
	Type        NodeType
	Name        string
	Description string
	Needs       []string
	When        string
	Concurrent  bool
	OnError     string
	Timeout     time.Duration
	// Attach names a request or subflow node of the same list that this node is shown
	// with: the canvas draws them as one block. It is a view only; the run order is
	// the list order, as always.
	Attach string
	// AttachAt says where, around that request, the canvas draws the node: "above" or
	// "below" it in a stack, or "" beside it (before it in the list is drawn left of it,
	// after it right of it). Like Attach it is a view only.
	AttachAt string

	Request  *RequestCall
	Subflow  *SubflowCall
	Body     []Node
	Branches []Branch
	Then     []Node
	Else     []Node
	Cases    []Case
	Params   []Field
}

Node is one step of a flow. Only the fields relevant to its Type are set. Type-specific options without a typed field are kept, in file order, in Params until the engine milestone types them.

func (Node) Children

func (n Node) Children() [][]Node

Children returns the node's non-empty nested node lists in a fixed order: body, branches, then, else, cases.

type NodeType

type NodeType string

NodeType names a kind of flow node.

func NodeTypes

func NodeTypes() []NodeType

NodeTypes returns every node type in catalogue order.

type Param

type Param struct {
	Name        string
	Type        ParamType
	Description string
	Default     string
}

Param is one declared blueprint parameter. A parameter without a Default must be given a value when the blueprint is used.

type ParamType

type ParamType string

ParamType is the kind of value a blueprint parameter takes.

const (
	ParamString     ParamType = "string"
	ParamInt        ParamType = "int"
	ParamBool       ParamType = "bool"
	ParamRequestRef ParamType = "request-ref"
	ParamFlowRef    ParamType = "flow-ref"
)

Parameter types. A request-ref or flow-ref parameter fills the places in the blueprint's nodes that name a request or a subflow ({param: name}); the other types become inputs of the flow made from the blueprint.

func ParamTypes

func ParamTypes() []ParamType

ParamTypes lists the parameter types in documentation order.

type Point

type Point struct{ X, Y int64 }

Point is a canvas position in canvas units.

type Ref

type Ref struct {
	Collection string
	ID         ID
	Path       string
	// Param, set only inside a blueprint, names the blueprint parameter
	// that fills this reference when the blueprint is used; ID and Path are
	// then empty.
	Param string
}

Ref points at a request or flow. Collection is empty for the referencing collection itself, otherwise the name or id of a declared dependency. ID is authoritative; Path is a readable hint that tools repair.

type Request

type Request struct {
	Meta
	Path      string
	Operation string // the OpenAPI operationId of its first version; Arazzo steps refer to it
	Default   string
	Versions  []RequestVersion
	Hooks     Hooks
	File      string

	// Edit is the one dirty edit: an autosaved working copy of a version.
	// Runs, serve and the CLI ignore it; only the GUI sends it. EditBase is
	// the label of the version it started from.
	Edit     *RequestVersion
	EditBase string
}

Request is a saved API request with one or more versions. Path is relative to requests/ without the .req.yaml suffix, e.g. "auth/login".

type RequestCall

type RequestCall struct {
	Request Ref
	Version string
	Hooks   HookControl
	With    []KeyValue
	Headers []KeyValue
}

RequestCall is the configuration of a request node.

type RequestVersion

type RequestVersion struct {
	Label string
	// Name is a short title for the version ("Before the tax change"); the label
	// ("1.1") stays what it is called everywhere else. Docs is its description.
	Name     string
	Method   string
	URL      string
	Query    []KeyValue
	Headers  []KeyValue
	Body     Body
	Extract  []Extraction
	Assert   []string
	Settings Settings
	Hooks    Hooks
	// Variables are the version's default values for {{var.name}}; the
	// environment's variable of the same name wins.
	Variables []KeyValue
	// Docs is the version's documentation, written as Markdown.
	Docs string
	// Async, when set, makes this an async (message) request instead of an
	// HTTP one: Method, Query and Body are then unused.
	Async *Async
	// GRPC, when set, makes this a gRPC call instead of an HTTP request. The
	// version's Headers are the call's metadata; Method, URL, Query and Body
	// are unused.
	GRPC *GRPC
}

RequestVersion is one complete definition of a request.

type RunTill

type RunTill struct {
	Until         string
	MaxIterations int
	MaxDuration   time.Duration
	Interval      time.Duration
}

RunTill repeats a whole flow until a condition or limit.

type Schedule

type Schedule struct {
	Name       string // unique within the workspace; names the schedule in logs and commands
	Flow       string // a flow path or id
	Collection string // optional: a collection name or id when Flow is ambiguous
	Cron       string // five fields, or @hourly, @daily, …
	Env        string // environment name; "" uses defaults.environment
	Inputs     []KeyValue
	TZ         string // IANA zone name; "" is the machine's zone
	Disabled   bool
}

Schedule runs a flow on a cron schedule while `flowi serve` is running. Schedules are personal, so they live in workspace.yaml, not in a collection.

type Settings

type Settings map[string]any

Settings maps dotted setting keys ("http.max_redirects") to values that the settings package has already validated.

type SubflowCall

type SubflowCall struct {
	Flow Ref
	With []KeyValue
}

SubflowCall is the configuration of a subflow node.

type Workspace

type Workspace struct {
	Meta
	Collections []Mount
	Schedules   []Schedule
	Settings    Settings
	File        string
}

Workspace is the content of workspace.yaml.

Jump to

Keyboard shortcuts

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