Architecture
Workflows run inside the Slung runtime as WASM modules. The runtime provides host functions for:- Live queries: Subscribe to streaming aggregates
- Historical queries: Query aggregated historical data
- Writeback: Send results to WebSocket clients or HTTP endpoints
- Event ingestion: Write events back to Slung
Host Functions
The Slung runtime exposes these host functions to WASM workflows:Query Syntax
All queries use the format:- OP:
AVG,MIN,MAX,SUM,COUNT - SERIES: Time series name
- TAGS: Filter using
AND,OR,NOToperators - RANGE: Optional time range (e.g.,
[1h],[1609459200000000,1609545600000000])
Examples
Workflow Lifecycle
- Initialize: Set up query handles and state
- Poll: Continuously poll handles for new events
- Process: Execute business logic on incoming events
- Writeback: Send results to destinations
- Cleanup: Free handles when done
Event Structure
Events returned by the runtime have this structure:Use Cases
- Real-time alerting and anomaly detection
- Stream processing and transformation
- Metric aggregation and downsampling
- Multi-stream correlation
- Event-driven automation
Next Steps
Getting Started
Build your first workflow with the Rust SDK
Live Queries
Subscribe to real-time stream updates
Historical Queries
Query aggregated historical data
Writeback
Send results to external systems