550c98f275
Reorganización física de crates/: - core/ (mezclaba 6 propósitos) se divide en protocol/, init/, runtime/, compat/ - shared/ (3 crates) se redistribuye en protocol/ e init/ - lapaloma (sub-módulo de ui_engine) se promueve a modules/pineal/ Renames de proyectos: - shipote → shuma (runtime de sandboxes) - nouser → akasha (explorador de Mónadas) - yahweh → nahual (motor GPUI, antes ui_engine/) - lapaloma → pineal (data-viz agnóstica) Fraccionamiento UI → core agnóstico: - vista-core (DeckState + snap, 175 LOC, 5 tests verdes) - barra-core (Task + render_html + sanitize, 90 LOC, 5 tests verdes) - vista-web y barra-web ahora son thin DOM bindings Documentación nueva: - 16 SDDs por subdirectorio (≤80 LOC c/u): protocol/init/runtime/compat + 10 módulos + apps/ - docs/STATUS.md con cifras reales por proyecto - docs/ROADMAP.md con plan a finalización (6 hitos, ~6-8 semanas) - CHANGELOG.md particionado en docs/changelog/<proyecto>.md (7 buckets) Automatización: - scripts/reorg.py — script idempotente que: git mv directorios, renombra package names, recomputa path = refs, reescribe imports rust, actualiza workspace Cargo.toml. Soporta --dry-run. - scripts/split-changelog.py — particiona CHANGELOG por componente. Validación: - cargo check --workspace pasa (124 crates + 2 nuevos cores). - 10 tests adicionales (5 en vista-core + 5 en barra-core) verdes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
84 lines
2.5 KiB
Rust
84 lines
2.5 KiB
Rust
//! `subscriber` — cliente brahman que loguea cada `MatchEvent` recibido.
|
|
//!
|
|
//! Declara una Card con un input `in` de tipo `json`. Cada vez que el
|
|
//! broker matchea (o desmatch) ese input contra un productor, imprime
|
|
//! una línea. Útil para visualizar la dinámica del broker en vivo.
|
|
//!
|
|
//! Uso:
|
|
//! ```sh
|
|
//! cargo run -p brahman-handshake --example subscriber [label]
|
|
//! ```
|
|
|
|
use std::collections::BTreeSet;
|
|
use std::time::Duration;
|
|
|
|
use brahman_card::{
|
|
ulid::Ulid, Card, Flow, Flows, Lifecycle, Payload, Priority, Supervision, TypeRef,
|
|
CARD_SCHEMA_VERSION,
|
|
};
|
|
use brahman_handshake::{client::Client, transport};
|
|
|
|
#[tokio::main(flavor = "current_thread")]
|
|
async fn main() -> anyhow::Result<()> {
|
|
let label = std::env::args()
|
|
.nth(1)
|
|
.unwrap_or_else(|| "subscriber".into());
|
|
|
|
let card = Card {
|
|
schema_version: CARD_SCHEMA_VERSION,
|
|
id: Ulid::new(),
|
|
label: label.clone(),
|
|
provides: BTreeSet::new(),
|
|
requires: BTreeSet::new(),
|
|
payload: Payload::Virtual,
|
|
supervision: Supervision::OneShot,
|
|
lifecycle: Lifecycle::Daemon,
|
|
priority: Priority::Normal,
|
|
flow: Flows {
|
|
input: vec![Flow {
|
|
name: "in".into(),
|
|
ty: TypeRef::Primitive {
|
|
name: "json".into(),
|
|
},
|
|
pin_to: None,
|
|
}],
|
|
output: vec![],
|
|
},
|
|
..Default::default()
|
|
};
|
|
|
|
let path = transport::default_socket_path();
|
|
eprintln!("[{label}] connecting to {}", path.display());
|
|
let mut client = Client::connect(&path, card).await?;
|
|
eprintln!(
|
|
"[{label}] attached: session={} init={}",
|
|
client.session(),
|
|
client.server_info().init_attached
|
|
);
|
|
|
|
// Loop: espera hasta 25s por un MatchEvent. Si timeout, ping para
|
|
// mantener la conexión viva.
|
|
loop {
|
|
match client.await_event(Duration::from_secs(25)).await? {
|
|
Some(ev) => {
|
|
eprintln!(
|
|
"[{label}] {:?} {} ← {}.{} via={:?}{}",
|
|
ev.kind,
|
|
ev.consumer_flow,
|
|
if ev.producer_label.is_empty() {
|
|
"<none>"
|
|
} else {
|
|
&ev.producer_label
|
|
},
|
|
ev.producer_flow,
|
|
ev.via,
|
|
if ev.pinned { " 📌" } else { "" }
|
|
);
|
|
}
|
|
None => {
|
|
let _ts = client.ping().await?;
|
|
}
|
|
}
|
|
}
|
|
}
|