<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.