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
<h1 align=center>
    BakBon
    <br>
    <img alt="Ferris" src="../docs/ferris.svg">
</h1>

## Table of Contents

- [Table of Contents]#table-of-contents
- [Overview]#overview
  - [Features]#features
- [Installation]#installation
- [File System]#file-system
- [Modules]#modules
- [Usage]#usage
- [Attribution]#attribution

## Overview

BakBon is an lightweight infrastructure microkernel library in Rust created to help configure, compose and build any type of message-driven distributed system whether it is microservices, blockchain insfrastructure IoT networks, by providing generic building blocks such as routers, gateways, balancers, queues, caching systems.

### Features

- **Protocol-Agnostic**: works with TCP, UDP, HTTP(s), gRPC, MQTT, Serial, InProc or custom protocols.
- **Composable**: mix and match different components (Router, Queue, Gateway, Balancer, Cache, etc).
- **Type-Safe**: strong typing with runtime flexibility.
- **Production-Ready**: Comprehensive [tests]./tests/, clean architecture.

## Installation

```
cargo add bakbon
```

## File System
```
πŸ“‚ bakbon
    β”‚
    β”œβ”€β”€ πŸ“‚ src
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ balancer
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ mod.rs
    β”‚       β”‚       └── πŸ“„ strategy.rs
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ cache.rs
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ builder.rs
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ eviction.rs
    β”‚       β”‚       └── πŸ“„ mod.rs
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ core
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ address.rs
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ error.rs
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ mod.rs
    β”‚       β”‚       └── πŸ“„ protocol.rs
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ infra
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ gateway.rs
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ middleware.rs
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ mod.rs
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ processor.rs
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ service.rs
    β”‚       β”‚       └── πŸ“„ storage.rs
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ message
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ envelope.rs
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ mod.rs
    β”‚       β”‚       └── πŸ“„ route.rs
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ queue
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“‚ attributes
    β”‚       β”‚       β”‚       β”‚
    β”‚       β”‚       β”‚       β”œβ”€β”€ πŸ“„ delivery.rs
    β”‚       β”‚       β”‚       β”œβ”€β”€ πŸ“„ durability.rs
    β”‚       β”‚       β”‚       β”œβ”€β”€ πŸ“„ mod.rs
    β”‚       β”‚       β”‚       β”œβ”€β”€ πŸ“„ ordering.rs
    β”‚       β”‚       β”‚       └── πŸ“„ provider.rs
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ builder.rs
    β”‚       β”‚       └── πŸ“„ mod.rs
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ registry
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ builder.rs
    β”‚       β”‚       └── πŸ“„ mod.rs
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ router
    β”‚       β”‚       β”‚ 
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ builder.rs
    β”‚       β”‚       └── πŸ“„ mod.rs
    β”‚       β”‚
    β”‚       └── πŸ“„ lib.rs
    β”‚
    β”œβ”€β”€ πŸ“‚ tests
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“‚ common
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“‚ services
    β”‚       β”‚       β”‚       β”‚
    β”‚       β”‚       β”‚       β”œβ”€β”€ πŸ“„ echo.rs
    β”‚       β”‚       β”‚       └── πŸ“„ mod.rs
    β”‚       β”‚       β”‚
    β”‚       β”‚       β”œβ”€β”€ πŸ“„ gateway.rs
    β”‚       β”‚       └── πŸ“„ mod.rs
    β”‚       β”‚
    β”‚       β”œβ”€β”€ πŸ“„ integration_gateway.rs
    β”‚       β”œβ”€β”€ πŸ“„ integration_queue.rs
    β”‚       └── πŸ“„ integration_router.rs
    β”‚
    β”œβ”€β”€ βš™οΈ Cargo.toml
    β”œβ”€β”€ πŸ”‘ LICENSE
    └── πŸ“– README.md

    14 directories, 40 files
```

## Modules

BakBon provides:
- **Balancer**: Balancer.
- **Cache**: Cache.
- **Core**: Address, Protocol, Error, Result.
- **Infra**: Gateway, Middleware, Processor, Service and Storage traits.
- **Message**: Envelope, Route, Reply, Headers, Payload.
- **Queue**: Queue.
- **Registry**: Registry.
- **Router**: Router.

## Usage

```rust
use bakbon::*;

let url = "http://services.com/echo";

// Create an address from url
let address: Result<Address> = Address::parse(url);
assert!(address.is_ok());

// Create a service with the address
let service = EchoService::new(address.unwrap());

// Register the service while building a registry
let registry = Registry::builder()
    .register(service)
    .build();

// Build a router
let mut router = Router::builder()
    .registry(registry)
    .build();

// Create a message.
let message = Envelope::new(client_addr, srv_addr, payload);

// Route the message to the appropriate service
let reply: Result<Reply> = router.route(message);
assert!(reply.is_ok());

```

## Attribution

If you use this project in your application, service, or research, please include the following credit:

> Based on **Bakbon** by Xn!l0 (https://github.com/Xnil0/backlab), licensed under the MIT License.