Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Overview

The cms-pipelines crate implements Hartmann pipelines – the VM/CMS mechanism for composing data transformations as a series of stages connected by pipes.

Pipeline Syntax

Pipelines are invoked with the PIPE command. Stages are separated by |:

PIPE literal Hello world | console
PIPE literal abc | locate /b/ | console
PIPE literal secret | nlocate /secret/ | console

Each stage reads records from its input, processes them, and writes records to its output. The first stage in a pipeline is a source (no input); the last is typically a sink.

Built-in Stages

StagePurpose
literalEmits its argument as a single output record
consoleWrites each input record to console output
locatePasses records containing a given string
nlocatePasses records NOT containing a given string

The Stage trait can be implemented to add custom stages.

Two-Pass Executor

The pipeline executor runs in two passes:

  1. Initialize – Each stage is created and connected to its neighbors via input/output channels.
  2. Process + Finish – Records flow through the pipeline. Each stage processes input records and produces output. When the source is exhausted, stages receive a finish signal to flush any buffered state.

Multi-Stream Support

Stages can produce output on primary and secondary streams. The return code from a stage determines which output stream receives the record:

RCMeaning
0Record written to primary output
4Record written to secondary output (e.g., non-matching in locate)
12End of stage processing

This allows filter stages like locate to split matching and non-matching records into separate streams.

Return Codes

Pipeline execution follows CMS conventions:

RCMeaning
0Pipeline completed successfully
24Syntax error or empty pipeline specification
28Stage not found
32Pipeline execution error

Integration with CMS

The pipeline subsystem is wired into cms-core’s CommandProcessor through the ExtCommandHandler trait. When a command starts with PIPE, the extension handler strips the prefix and passes the rest to run_pipe(). Results (return code and output messages) are returned through the standard command result path.