Skip to content

Feat(backend, pipeline): pipeline module - #684

Merged
JavierRibaldelRio merged 21 commits into
new-backendfrom
backend/pipeline
Dec 6, 2026
Merged

JavierRibaldelRio merged 21 commits into
new-backendfrom
backend/pipeline

Conversation

@GaziH

@GaziH GaziH commented Dec 1, 2026 •

Copy link
Copy Markdown

What pipeline is

station::pipeline turns what station::event routes to the front into station::payload models and publishes them through station::websocket::broker::BrokerClient.

  • Immediate: board connections, triggered protections and board messages, plus the backend's own notices and order outcomes.
  • Every 100 ms: telemetry (Packet::Data), aggregated per packet into podData/update with cumulative count, mean cycleTime and, per measurement, last and the window average.

The design and the topic mapping are documented in backend/crates/station/src/pipeline/README.md.

Changes

station::pipeline

crates/station/src/
├── pipeline.rs              # Config, spawn, biased select! loop (tick → ⑥ → ⑨), routing
└── pipeline/
    ├── accumulator.rs       # 100 ms telemetry windowing (count, cycle_time, last, average)
    ├── message.rs           # message/update and backend/message builders
    ├── timestamp.rs         # SystemTime / ShortTimestamp -> UTC MessageTimestamp
    ├── tests.rs             # unit tests against a real Broker (no sockets)
    └── README.md
  • Topic mapping:
    • Event::Connected / Event::Disconnected → connection/update (whole map, only on change)
    • Packet::Data (queue ⑨) → podData/update, every 100 ms
    • Packet::Protection → protection/update
    • Packet::Message → message/update (board messages only: origin from the packet, name = the level's ADJ name)
    • ToPipeline::Notice → backend/message (Info → info, Warning → warning, Fatal → fault, Silent ignored)
    • ToPipeline::OrderSent / OrderFailed → backend/message ("Order Start sent", "Order Start not sent: <reason>")
  • Frontend liveness is websocket's, not pipeline's.

station::event: telemetry on its own queue

event now feeds pipeline through two queues, so a slow front can never stall the backend:

  • ⑥ channels.pipeline (ToPipeline, 1024): everything but telemetry. event waits when it is full: nothing there may be lost.
  • ⑨ channels.pipeline_data (Arc<Notification>, only Packet::Data, 8192 ≈ 200 ms at 41 k/s): event uses try_send. When ⑨ is full it drops the front's copy (logging already got it), warns when it starts dropping and reports how many it dropped once ⑨ has room again. A closed ⑨ means pipeline is gone: fatal, as before.

pipeline reads ⑥ before ⑨, so protections and messages never wait behind telemetry, and it ends once both queues are closed. It has no saturation logic of its own.

Supporting changes

  • lib.rs: pub mod pipeline; the module list in the docs.
  • main.rs: the pipeline stand-in reads ⑥ and ⑨ and counts telemetry. The real pipeline needs the websocket broker, which main does not start yet.
  • station/README.md, readme-demo.md, event/README.md: updated to match.

Testing

cargo test -p station
cargo test -p station --release manual_event -- --ignored --nocapture
  • pipeline::tests (ADJ fixture with two boards):
    • immediate forwarding; every board disconnected at startup and connections published only on change;
    • notices and order outcomes on backend/message (and nothing of the backend's on message/update);
    • 100 ms windowing with paused Tokio time; the whole podData/update map on every flush, and nothing for an empty window;
    • the task ending, with a final flush, only once both queues are closed, and as soon as the broker is gone (closing ⑥ and ⑨);
    • the accumulator's defensive paths (non-data ids, a clock stepping back, malformed packets); UTC timestamp conversion.
  • event::tests, new: telemetry on ⑨ and everything else on ⑥; a full ⑨ dropping the front's copy without stopping event; a closed ⑨ being fatal.
  • manual_event_throughput: about 1,000,000 notifications/s in release, over 20 times the requirement.
  • End to end with chimera-sender (7 boards, ~730 packets/s for 15 s): logging and the pipeline stand-in both got 9,928 packets, nothing dropped, exit code 0 on Ctrl+C.

Open points

  1. order/stateOrders is not published: software_core::model::Packet has no state-orders variant.
  2. websocket still has to send the Fatal notice when the frontend is lost (its TODO).
  3. feat(backend, net::tcp): implement per-board TCP clients with reconnection, keep-alive and fault broadcast #672 (net-tcp) also changes event (router.rs, event.rs, its tests and README) and main.rs: whichever merges second resolves the conflicts.

Gazi Al Saad Halawani and others added 7 commits November 24, 2026 21:08
Add pipeline module so Javier can have a look
# Conflicts:
#	backend/crates/core/src/lib.rs
# Conflicts:
#	backend/crates/core/src/lib.rs
#	backend/crates/station/src/main.rs
…oads" -m "- Move pipeline from software-core into station (crates/station/src/pipeline.rs)

 - Map ToPipeline variants (connections, protections, board messages, problems, order outcomes) to payload types and publish immediately via BrokerClient
 - Aggregate Packet::Data telemetry per packet ID over 100 ms windows (cumulative count, mean cycle_time, per-measurement last and window average) and flush on shutdown
  - Re-export MeasurementUpdate, MessageKind, MessagePayload, and MessageTimestamp from station::payload
  - Expose event and pipeline from station::lib so station modules share crate-level imports
  - Add unit tests for immediate event forwarding, 100 ms data windowing, and UTC calendar timestamp conversion
…ar format as rest of station. Created README
@GaziH
GaziH changed the base branch from develop to backend/net December 1, 2026 21:09
@GaziH
GaziH marked this pull request as draft December 3, 2026 16:20
@GaziH GaziH changed the title Feat(backend, pipeline): implement station::pipeline for event-to-WebSocket payload routing and 100 ms telemetry aggregation Feat(backend, pipeline): pipeline module Dec 3, 2026
@GaziH
GaziH changed the base branch from backend/net to new-backend December 5, 2026 09:16
@JavierRibaldelRio
JavierRibaldelRio marked this pull request as ready for review December 6, 2026 09:12
…lator

- The fixture gets a second board (BCU, data packet 661).
- Every flush publishes the whole podData map; an empty window nothing.
- Every board disconnected at startup; connections only on change.
- pipeline stops when the broker is gone, closing both queues.
- Accumulator: non-data ids, clock stepping back, malformed packets.
@JavierRibaldelRio
JavierRibaldelRio merged commit f0f22c3 into new-backend Dec 6, 2026
2 checks passed
@JavierRibaldelRio
JavierRibaldelRio deleted the backend/pipeline branch December 6, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants