Different pipes. One standard.

Type to search this site.

Search runs in your browser against a static index built with this site (Pagefind). Nothing you type is sent to a server.

How does a program get a second input or output?

Available — v0.0.1 (experimental)go

Go multi-port validation

One compiled program, three output streams. stdout carries the main one; the others are POSTed to loopback endpoints the runner hands it. No SDK: standard library only.

Available in v0.0.1: the files, README and tests are in examples/go-multiport-validate of the openflange-go repository. Commands run from the repository root.

Needs: Go, to build the program.

A pipe is a data-processing step with declared inputs and outputs.

What goes in, what comes out

Input (stdin)
{"id":1,"email":"alice@example.com"}
{"id":2,"email":"not-an-address"}
{"id":3,"email":"bob@example.org"}
Command
go build -o examples/go-multiport-validate/bin/validate-email ./examples/go-multiport-validate && printf '%s\n' '{"id":1,"email":"alice@example.com"}' '{"id":2,"email":"not-an-address"}' '{"id":3,"email":"bob@example.org"}' | openflange run ./examples/go-multiport-validate --grant subprocess --output valid=- --output rejected=rejected.ndjson --output stats=stats.ndjson
Outputs
# valid (stdout)
{"id":1,"email":"alice@example.com"}
{"id":3,"email":"bob@example.org"}
# rejected.ndjson
{"record":{"id":2,"email":"not-an-address"},"reason":"expected exactly one @"}
# stats.ndjson
{"rejected":1,"total":3,"valid":2}

Files and further commands

What the program is told — the file named by $OPENFLANGE_CONFIG
{"spec": "openflange.org/cli/v0.1",
 "pipe": {"id": "validate-email", "version": "0.1.0"},
 "parameters": {},
 "inputs":  {"records":  {"enabled": true, "transport": "stdin",  "mediaType": "application/x-ndjson"}},
 "outputs": {"valid":    {"enabled": true, "transport": "stdout", "mediaType": "application/x-ndjson"},
             "rejected": {"enabled": true, "transport": "http", "url": "http://127.0.0.1:41873/outputs/rejected", "mediaType": "application/x-ndjson"},
             "stats":    {"enabled": true, "transport": "http", "url": "http://127.0.0.1:41873/outputs/stats", "mediaType": "application/x-ndjson"}},
 "token": "<opaque, scoped to this execution>"}

What to notice

  • The runner writes the config file (mode 0600) and passes its path in OPENFLANGE_CONFIG, never on the command line. The port number and the token differ per run.
  • For each other enabled output the program opens one POST <url> with Authorization: Bearer <token> and streams NDJSON as the request body. The runner owns the endpoints and answers 204.
  • rejected is a required output here: openflange run refuses to start until it is bound. stats is optional; leave it unconnected and it is never computed.
  • The token is scoped to this one execution and is never logged. A subprocess is not a sandbox.