Add compose-metrics.ds (Layer 1): receives counter+clock+stats, derives uptime/events/status, re-streams on /peer/metrics. This app is BOTH a receiver and a source. Add compose-master.ds (Layer 2): receives chained metrics from Layer 1 + mood direct from Layer 0. Demonstrates multi-layer signal composition with independent stream mixing. Verified: Uptime: 51s, Total Events: 9 flowing through the full three-layer chain to the master dashboard.
42 lines
1.4 KiB
Text
42 lines
1.4 KiB
Text
-- DreamStack Chained Composition — Layer 2: Master Dashboard
|
|
-- Receives the aggregated metrics (from Layer 1) AND mood (from Layer 0).
|
|
--
|
|
-- Architecture:
|
|
-- Counter ──┐
|
|
-- Clock ───┤──► compose-metrics ──┐
|
|
-- Stats ───┘ (Layer 1) │
|
|
-- ├──► THIS APP (Layer 2)
|
|
-- Mood ────────────────────────────┘
|
|
--
|
|
-- This demonstrates:
|
|
-- 1. Chained composition (3 → 1 → final)
|
|
-- 2. Multiple layers of signal derivation
|
|
-- 3. Mixing independently-sourced streams
|
|
--
|
|
-- Run with:
|
|
-- dreamstack build examples/compose-master.ds
|
|
|
|
let metrics = stream from "ws://localhost:9100/stream/metrics"
|
|
let mood = stream from "ws://localhost:9100/stream/mood"
|
|
|
|
view main =
|
|
column [
|
|
text "🏗️ Master Dashboard (Layer 2)"
|
|
text "Chained: 3→1→here + mood"
|
|
row [
|
|
column [
|
|
text "── ⚡ Aggregated Metrics ──"
|
|
text "(from compose-metrics)"
|
|
text "Uptime: {metrics.uptime}s"
|
|
text "Total Events: {metrics.events}"
|
|
text "Status: {metrics.status}"
|
|
]
|
|
column [
|
|
text "── 😊 Mood (Direct) ──"
|
|
text "(from streaming-mood)"
|
|
text "Mood: {mood.mood}"
|
|
text "Energy: {mood.energy}%"
|
|
text "Color: {mood.color}"
|
|
]
|
|
]
|
|
]
|