bakbon 0.1.2

BakBon is an infrastructure microkernel library in Rust that provides generic building blocks (Router, Registry, Balancer, Queue, Gateway, Cache, Middleware, Service/Processor) for message‑driven distributed systems.
Documentation
//! BakBon - Infrastructure Microkernel for Distributed Systems
//!
//! BakBon provides protocol-agnostic building blocks for message-driven
//! distributed systems. Build microservices, IoT networks, or blockchain
//! infrastructure with composable, type-safe components.
//!
//! # Modules
//!
//! - `Balancer`: [`Balancer`] for load balancing.
//! - `Core`: [`Address`], [`Protocol`], [`Error`], [`Result`].
//! - `Discovery`: [`Registry`] for service discovery.
//! - `Gateway`: [`Gateway`] for network communication.
//! - `Message`: [`Envelope`], [`Headers`], [`Payload`], [`Reply`].
//! - `Infra`: [`Cache`], [`Middleware`].
//! - `Queue`: [`Queue`] and delivery semantics.
//! - `Routing`: [`Router`] for message routing.
//! - `Service`: [`Service`] and [`Processor`] traits.
//!
//! # Quick Example
//!
//! ```rust
//! use bakbon::prelude::*;
//!
//!     // Create addresses.
//!     let source = Address::parse("http://client-address.com");
//!     let destination = Address::parse("grpc://service.com/echo");
//!     assert!(source.is_ok());
//!     assert!(destination.is_ok());
//!     let src = source.unwrap();
//!     let dst = destination.unwrap();
//!
//!     // Create a payload from the bytes crate.
//!     let payload = Payload::from("Hello there");
//!
//!     // Create a message envelope.
//!     let message = Envelope::new(src, dst.clone() , payload);
//!
//!     // Create a service.
//!     #[derive(Debug)]
//!     struct NilService(Address);
//!
//!     impl Service for NilService {
//!         fn address(&self) -> &Address { &self.0 }
//!         fn duplicate(&self) -> ServiceBox { Box::new(Self(self.0.clone())) }
//!         fn process(&self, msg: Envelope) -> Result<Reply> { Ok(None) }
//!     }
//!
//!     let service = NilService(dst);
//!
//!     // Create a service registry.
//!     let registry = Registry::builder()
//!         .register(service)
//!         .build();
//!
//!     // Create a router.
//!     let mut router = Router::builder()
//!         .registry(registry)
//!         .build();
//!
//!     // Route the created message.
//!     let reply = router.route(message);
//!     assert!(reply.is_ok());
//!     let reply = reply.unwrap();
//!     assert!(reply.is_none());
//! ```
mod balancer;
mod cache;
mod core;
mod infra;
mod message;
mod queue;
mod registry;
mod router;

pub use {
    balancer::Balancer,
    bytes,
    cache::Cache,
    core::{
        Address,
        Error,
        Protocol,
        Result,
    },
    infra::{
        Gateway,
        Middleware,
        ProcMap,
        Processor,
        Service,
        ServiceBox,
        ServiceMap,
        ServiceVec,
        Storage,
    },
    message::{
        Envelope,
        Headers,
        Payload,
        Reply,
    },
    queue::Queue,
    registry::Registry,
    router::Router,
};

pub mod prelude {
    pub use crate::{
        Address,
        Balancer,
        Cache,
        Envelope,
        Error,
        Gateway,
        Headers,
        Middleware,
        Payload,
        ProcMap,
        Processor,
        Protocol,
        Queue,
        Registry,
        Reply,
        Result,
        Router,
        Service,
        ServiceBox,
        ServiceMap,
        ServiceVec,
        Storage,
    };
}