Ports #
| Port | Direction | Kind | Required | Description |
|---|---|---|---|---|
in | input | records | yes | |
out | output | records | yes |
Parameters #
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
count | integer | none | yes | Minimum 0. |
When to use it #
- Run a new pipeline on a small sample of a large input before running it on everything.
- Together with
std:skip, take one page of a stream: skip 200, then limit 100.
When to use something else
- It counts records and does not look at them: to choose records by a condition use
std:filter. The rest of the input is consumed and discarded, and the run completes normally.
A tested example #
Nothing here is invented: this is the test “first two” from the pipe's own portable test file, which every conformant runner must pass.
{
"count": 2
}"a"
"b"
"c""a"
"b"The same step as a node of a pipeline.yaml:
nodes:
limit:
pipe: std:limit
inputs:
in: {from: inputs.in}
parameters:
count: 2Run it #
The pipe runs on its own from a shell. The input is the test input above. The quickstart shows how to get the openflange command.
printf '%s\n' '"a"' '"b"' '"c"' | openflange run std:limit --param count=2"a"
"b"Executed with openflange 0.0.1 (go1.27.1 linux/amd64), built from commit 11cf8cc of the reference implementation; the output shown is what it printed, and it matches the test.
Notes from the manifest #
The pipe's manifest, OPENFLANGE.md, carries these notes.
Part of the OpenFlange standard library (std, version 0.1).
Passes the first count items unchanged (they are never decoded) and then
completes. The runner tells the upstream producer that nobody reads the
stream any more, so an unbounded source ends too — like head in a Unix
pipeline. count: 0 emits nothing.
Reference #
- Maturity
- Experimental
- Processing scope
record- Manifest version
0.1.0
- Normative definition: std:limit in the standard library specification
- Manifest and tests: std/0.1/limit in the specification repository