Principle:1kbgz Tributary Stream Sinks
| Knowledge Sources | |
|---|---|
| Domains | Streaming, Data_Output |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
Terminal nodes in a streaming pipeline that consume data for side effects: printing, collecting, logging, persisting, or visualizing, without producing further downstream values.
Description
Stream sinks are the output endpoints of a streaming pipeline. They consume values from an upstream node and produce side effects rather than passing values downstream. Sinks are the observers in the reactive streams model.
Categories of sinks:
- Display: Print writes to stdout, Logging uses Python's logging module.
- Collection: Collect accumulates values into a list for testing.
- Persistence: File writes to disk, Postgres writes to a database, Kafka publishes to a topic.
- Network: HTTP POSTs to an endpoint, WebSocket pushes to clients, SSE streams events.
- Notification: Email sends emails, TextMessage sends SMS via Twilio.
- Visualization: GraphViz renders the graph structure, Dagre provides interactive visualization, Perspective displays in a widget.
Sinks typically wire themselves to the upstream node automatically: the sink function takes the upstream node as its first argument and creates a new Node wired via >>.
Usage
Use these when you need to output, persist, or visualize streaming data. Choose the sink based on the destination: stdout for debugging, Collect for testing, File/Postgres/Kafka for persistence, Email/SMS for alerting, GraphViz/Dagre for debugging the graph structure.
Theoretical Basis
Sinks implement the observer pattern: they subscribe to an upstream node and react to each emitted value. Unlike intermediate nodes, sinks consume values without producing downstream output.
# Abstract sink model (NOT real implementation)
def sink(upstream, effect):
async def consume(value):
effect(value) # side effect (print, write, send)
return value # pass-through for potential chaining
node = Node(func=consume, inputs=1)
upstream >> node
return node
Sinks are terminal nodes: they have downstream connections only for the purpose of graph traversal (the output node is often a sink). The side effect occurs in the node's callable.