How sabledb-io/sabledb works
Main Components
• Core Library (libsabledb): This is the backbone of SableDB, encapsulating modules such as:
• Commands: Handling various command sets (base, client, server, locking, transactions, etc.)
• I/O & Network: Managing file output, RESP protocol writing, TLS connectivity, and transport.
• Metadata: Managing key metadata, expiration, and encoding.
• Replication: Modules for client/server replication, transaction log tailing, cluster management and storage updates.
• Storage: Abstractions for RocksDB integration with specialized databases for strings, hashes, lists, etc.
• Utility Modules: Supporting file operations, pattern matching, request parsing, and monitoring (ticker, stopwatch).
• Server Binary (sabledb): The entry point for starting the database server (main.rs) that integrates the core functionalities.
• Client & Admin Tools (sdb-cli and sdb-admin): These command line binaries provide interfaces for interacting with and administrating the database.
• Docker & Deployment: Dockerfile, docker-compose.yaml, and related scripts facilitate containerization and deployment.
Relationships & Interactions
• The Server (sabledb) uses libsabledb to handle incoming requests (via its net module) and routes commands to appropriate handlers in the commands module.
• The I/O/Network layer processes client connections (supporting TLS from ssl files) and communicates using the RESP protocol.
• The Storage layer, which wraps around RocksDB, interacts with command handlers to persist and retrieve data.
• The Metadata and Replication modules work alongside the storage engine to ensure data consistency, transactional support, and replication across nodes.
• CLI tools (sdb-cli) and admin utilities (sdb-admin) interface with the server using the defined protocol to issue commands and manage the cluster.
• Docker configuration and CI/CD workflows (in .github/workflows) coordinate builds, tests, and deployment, ensuring consistency across environments.
Architectural Patterns & Principles
• Modularity: The project is well separated into many modules (commands, storage, replication, etc.), enabling high cohesion within components.
• Layered Design: There’s a clear separation between networking, command processing, storage, and replication.
• Extensibility: With support for multiple command types and a wide array of protocols, the design embraces extension points (e.g., additional commands or storage backends).
• Asynchronous & Concurrent Programming: Integration of asynchronous operations, especially in networking and replication layers (inspired by Tokio), suggests clear concurrency management.
Relevant Technologies & Frameworks
• Rust as the programming language.
• Cargo for package management and project building.
• RocksDB as the storage engine.
• TLS support (evidenced by the ssl directory and net/tls module).
• Docker for containerization.
• CI/CD workflows shown via GitHub Actions.
• Benchmarking tools (sb) to test performance.
• Since SableDB is primarily a backend database service, emphasize critical boundaries:
• Separate the “Client Layer” (sdb-cli, sdb-admin, and external connections) from the “Server Core” (sabledb binary).
• Data flow: from client request to network layer, command parsing, metadata/replication handling and storage interaction.
Detailing Additional Architectural Elements
• Error handling and concurrency aspects in server modules.
• Possibly include a separate layer or note for testing (integration tests in libsabledb/src/integtests) to show how the system is validated.
• Configuration elements (server.ini, build scripts) that allow flexible deployment.