Examples
Runnable workflow examples and service-backed templates.
Local examples
These run with only Go.
go run ./cmd/mailer-workflow --file examples/workflows/wordcount.yaml
go run ./cmd/mailer-workflow --file examples/workflows/order-totals.yamlWord count
name: wordcount
source:
type: generator
records:
- {key: hello, value: '{"word":"hello"}'}
- {key: mailer, value: '{"word":"mailer"}'}
- {key: hello, value: '{"word":"hello"}'}
pipeline:
- id: by-word
type: keyBy
keyBy: {field: word, partitions: 1}
- id: count
type: reduce
reduce: {function: count}
sink:
type: stdoutOrder totals
name: order-totals
source:
type: generator
records:
- key: order-1
value: '{"customer":{"id":"c1"},"status":"completed","amount":10}'
- key: order-2
value: '{"customer":{"id":"c1"},"status":"pending","amount":15}'
- key: order-3
value: '{"customer":{"id":"c1"},"status":"completed","amount":5}'
- key: order-4
value: '{"customer":{"id":"c2"},"status":"completed","amount":7}'
pipeline:
- id: completed
type: filter
filter: {field: status, operator: equals, value: completed}
- id: by-customer
type: keyBy
keyBy: {field: customer.id, partitions: 1}
- id: totals
type: reduce
reduce: {function: sum, field: amount}
sink:
type: stdoutService-backed examples
These require external services and environment variables.
| File | Requires |
|---|---|
examples/workflows/kafka-to-kafka-exactly-once.yaml | Kafka and KAFKA_USERNAME / KAFKA_PASSWORD when SASL is enabled. |
examples/workflows/postgres-sink.yaml | Kafka, Postgres, POSTGRES_DSN, and Kafka credentials when SASL is enabled. |
Use --dry-run --describe first to validate the config without executing the
pipeline.
SDK examples in the repository
| Directory | Demonstrates |
|---|---|
examples/wordcount | FlatMap, KeyBy, Reduce. |
examples/windowing | Event time, watermarks, tumbling windows. |
examples/backpressure | Bounded edges and slow sink backpressure. |
examples/exactly-once | Kafka source to transactional Kafka sink. |
examples/kafka-orders | Kafka order pipeline. |
examples/kafka-dashboard | Kafka pipeline with dashboard. |
examples/pg-orders | Kafka to Postgres. |
examples/dashboard-demo | Metrics and dashboard demo. |