hyprstream_workers/events/mod.rs
1//! Event bus infrastructure — moq-lite backed (#167).
2//!
3//! Provides fan-out event delivery between services using the moq-lite streaming
4//! plane. Replaces the former ZMQ XPUB/XSUB ProxyService.
5//!
6//! # Architecture
7//!
8//! ```text
9//! Publishers MoqEventOrigin (global) Subscribers
10//! ┌─────────────┐ ┌──────────────────────┐ ┌──────────┐
11//! │WorkerService │──moq────►│ local/events/worker │─────►│Workflow- │
12//! │RegistryService│ │ local/events/system │ │ Service │
13//! │ │ │ local/events/registry│ └──────────┘
14//! └─────────────┘ └──────────────────────┘
15//! ```
16//!
17//! `EventPublisher`/`EventSubscriber` are the canonical broadcast types
18//! (EV1, EventService consolidation epic #600) and live in
19//! `hyprstream-rpc::events` alongside the moq transport and crypto they wire
20//! together. Import them from that canonical module.
21//! Default privacy mode is `EventPrivacy::Public` (plaintext, wire-identical
22//! to the pre-EV1 behavior of this crate's old standalone wrapper);
23//! `EventPrivacy::ZeroKnowledge`/`LimitedKnowledge` group-key encrypted modes
24//! are also available — see `hyprstream_rpc::events` docs.
25//!
26//! # Usage
27//!
28//! ```ignore
29//! use hyprstream_rpc::events::{EventPublisher, EventSubscriber};
30//!
31//! // Create a publisher (no ZMQ context needed)
32//! let publisher = EventPublisher::new("worker")?;
33//! publisher.publish("sandbox123", "started", &payload).await?;
34//!
35//! // Create a subscriber
36//! let mut subscriber = EventSubscriber::new()?;
37//! subscriber.subscribe("worker.")?;
38//! while let Ok((topic, payload)) = subscriber.recv().await {
39//! println!("Received: {}", topic);
40//! }
41//! ```
42
43pub mod token_manager;
44mod types;
45
46// Re-export event types
47pub use types::{
48 // Serialization helpers
49 serialize_container_started,
50 serialize_container_stopped,
51 serialize_sandbox_started,
52 serialize_sandbox_stopped,
53 // Individual event structs (with ToCapnp/FromCapnp)
54 ContainerStarted,
55 ContainerStopped,
56 // EventSubscriber integration
57 ReceivedEvent,
58 SandboxStarted,
59 SandboxStopped,
60 // Union enum for type-safe handling
61 WorkerEvent,
62};
63
64pub use token_manager::EventTokenManager;