Skip to main content
Version: 0.11

Passthrough

note

All the application code here is available from the docs git repository.

The passthrough example is the simplest possible configuration of tremor. It shows the very basic building blocks: Onramp, Offramp, Binding, Mapping and Pipeline.

Environment

The onramp we use is a websocket onramp listening on port 4242, it receives JSON formatted messages.

onramp:
- id: ws-input # A unique id for binding/mapping
type: ws # The unique type descriptor for the onramp ( websocket server here)
codec: json # The underlying data format expected for application payload data
config:
port: 4242 # The TCP port to listen on
host: "0.0.0.0" # The IP address to bind on ( all interfaces in this case )

It connects to the pipeline example in the example.trickle file using the trickle query language to express its logic.

The offramp we used is a console offramp producing to standard output. It receives JSON formatted messages.

offramp:
- id: stdout-output # The unique id for binding/mapping
type: stdout # The unique type descriptor for the offramp ( stdout here )
codec: json # The underlying data format expected for application payload data
config:
prefix: ">> " # A prefix for data emitted on standard output by this offramp

The binding expresses those relations and gives the graph of onramp, pipeline and offramp.

binding:
- id: example # The unique name of this binding template
links:
"/onramp/ws-input/{instance}/out": # Connect the input to the pipeline
- "/pipeline/example/{instance}/in"
"/pipeline/example/{instance}/out": # Connect the pipeline to the output
- "/offramp/stdout-output/{instance}/in"

Finally the mapping instanciates the binding with the given name and instance variable to activate the elements of the binding.

Business Logic

select event from in into out

Command line testing during logic development

Run a the passthrough query against a sample input.json

$ tremor run -i input.json etc/tremor/config/example.trickle
{"hello": "world"}

Deploy the solution into a docker environment

$ docker-compose up
>> {"hello": "world", "selected": false}
>> {"hello": "again", "selected": true}

Inject test messages via websocat

note

Can be installed via cargo install websocat for the lazy/impatient amongst us

$ cat inputs.txt | websocat ws://localhost:4242
...