Modular software deployed on mini compute units in controlled distributed environments often needs two messaging paths: low-overhead in-process coordination and selective cross-node distribution. In practice, event identity, serialization, and transport bridging are frequently implemented as ad hoc glue, which complicates inter-process communication (IPC), structured routing, and shutdown behavior. This paper presents CNS, a lightweight local-first hybrid event fabric centered on asynchronous fire-and-forget messaging. CNS combines a typed event key, per-family serialization and validation, a local publish/subscribe context for in-process coordination, and a NATS-backed distributed context for inter-node distribution. A bridge runtime moves events between the two contexts while preserving a common routing vocabulary. The primary operating model is fire-and-forget publication and subscription; bidirectional request-reply remains available as a secondary extension on the same subject space. A Python prototype and single-machine measurements are reported. Local-only delivery averaged about 30 $μ$s. Distributed-only delivery averaged 1.26-1.37 ms, and the hybrid bridge averaged 1.64-1.89 ms. Validation introduced modest overhead relative to serialization choice. The resulting artifact is suited to structured IPC and practical message movement within modular services and across bounded sets of controlled nodes.
翻译:在受控分布式环境中部署于微型计算单元的模块化软件通常需要两种消息传递路径:低开销的进程内协调与选择性跨节点分发。实践中,事件标识、序列化及传输桥接常以临时胶合代码实现,这导致进程间通信(IPC)、结构化路由和关闭行为复杂化。本文提出CNS——一种以异步即发即忘消息传递为核心的轻量级本地优先混合事件框架。CNS融合了类型化事件键、按类族序列化与验证、用于进程内协调的本地发布/订阅上下文,以及基于NATS的分布式上下文用于跨节点分发。桥接运行时在保持公共路由词汇表的同时在两种上下文间移动事件。其核心操作模型为即发即忘发布/订阅;同一主题空间上的双向请求-回复作为次级扩展仍可用。本文报告了一个Python原型及单机测量结果。仅本地投递平均耗时约30微秒。仅分布式投递平均耗时1.26-1.37毫秒,混合桥接平均耗时1.64-1.89毫秒。验证引入的开销相对于序列化选择较为适度。该成果适用于结构化IPC以及模块化服务内部和有限受控节点集之间实用的消息移动。