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
- func AsyncBindings(p string) []string
- func AsyncCredentials(p string) []string
- func AsyncProtocols() []string
- func AsyncSchemes(p string) []string
- func CloudProtocol(p string) bool
- func DefaultEnvColour(name string) string
- func EnvColours() []string
- func GRPCTarget(server string) (hostport string, useTLS bool)
- func GRPCTargetURL(server, method string) string
- func JoinURL(server, channel string) string
- func KnownProtocol(p string) bool
- func NormalizeServer(protocol, server string) string
- func ProtocolOfVerb(verb string) string
- func ProtocolVerb(protocol string) string
- func RedactedTarget(target string) string
- func SplitMethod(m string) (service, method string, ok bool)
- func TargetURL(protocol, server, channel string) string
- type Async
- type AsyncReceive
- type AsyncSend
- type Blueprint
- type Body
- type Branch
- type Case
- type Collection
- type Dependency
- type EnvVar
- type Environment
- type Execution
- type Extraction
- type Field
- type Flow
- type Folder
- type GRPC
- type HookControl
- type HookStep
- type Hooks
- type ID
- type Input
- type KeyValue
- type Layout
- type Manifest
- type Meta
- type Mount
- type Node
- type NodeType
- type Param
- type ParamType
- type Point
- type Ref
- type Request
- type RequestCall
- type RequestVersion
- type RunTill
- type Schedule
- type Settings
- type SubflowCall
- type Workspace
Constants ¶
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.
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.
const ( GRPCSchemePlaintext = "grpc" GRPCSchemeTLS = "grpcs" )
The URL schemes of a gRPC server.
const ( AsyncSendOnly = "send" AsyncReceiveOnly = "receive" AsyncRequestReply = "request_reply" )
The actions an Async version can have.
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 ¶
AsyncBindings are the binding names protocol p understands.
func AsyncCredentials ¶
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 ¶
AsyncSchemes are the URL schemes a server of protocol p may use.
func CloudProtocol ¶
CloudProtocol reports whether p is a cloud service with an `auth` mode: the provider's default login, or the explicit credential bindings.
func DefaultEnvColour ¶
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 ¶
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 ¶
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 ¶
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 ¶
KnownProtocol reports whether p is an async protocol.
func NormalizeServer ¶
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 ¶
ProtocolOfVerb is the protocol a verb stands for, or "" when it is not one (an HTTP method).
func ProtocolVerb ¶
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 ¶
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 ¶
SplitMethod splits package.Service/Method into the service and method names. A leading slash (grpcurl's way of writing it) is allowed.
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).
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 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 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 ¶
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 ¶
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 ¶
HookControl decides which API hooks a request node runs. Mode is "all" (default) or "none"; Skip lists "pre" and/or "post".
type HookStep ¶
HookStep is one pre or post hook: a reusable flow or inline nodes. Exactly one of Flow and Inline is set.
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 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.
type Param ¶
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 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 ¶
Settings maps dotted setting keys ("http.max_redirects") to values that the settings package has already validated.
type SubflowCall ¶
SubflowCall is the configuration of a subflow node.