How heqingpan/rnacos works
Main Components
• API Gateways:
– HTTP server: Exposes the RESTful APIs including configuration and naming APIs.
– GRPC server: Serves gRPC requests (for 2.x protocol support including instance notifications, heartbeats, etc.).
• Management Console:
– A dedicated service (runs on its own port, as seen from the README and the src/console modules) and is implemented as a separate front‑end/back‑end (with static resources integrated via Cargo).
• Core Modules:
– Config Center: Handles configuration management (create, update, history, import/export) and its persistence.
– Naming/Service Registry: Manages service instances, registration, discovery, and heartbeat mechanisms.
– Raft & Distributed Storage: Provides clustering and high availability via the raft protocol recoded in modules under src/raft (and related file storage, snapshotting, and network components).
– OpenAPI Layer: Exposes endpoints for third‑party clients and integrations.
– Metrics & Health: Modules under src/metrics, src/health that collect, expose, and log performance and system health data.
• Utility and Supporting Modules:
– Common utilities (logging, error handling, cryptography, web utilities in src/common).
– Namespace management, user/permission management (important for the console and security).
– Transfer modules (data migration/backup, e.g., from SQLite/MySQL).
Relationships and Interactions
• Clients (SDKs in various languages, HTTP REST clients, gRPC clients) interact with the API Gateway.
• The API Gateway (HTTP and GRPC endpoints) routes requests to the respective core business logic (config center, naming center).
• The Management Console interacts with the API layer to allow administrators to manage users, services, configurations, and view metrics.
• The underlying cluster nodes communicate using Raft. They exchange state information and maintain consensus on configuration/naming updates.
• Persistence is maintained locally (using file storage) in each node, and the raft module ensures these are consistent across nodes.
• Health and metrics modules continuously monitor the runtime performance and provide aggregator endpoints.
Architectural Patterns and Important Technologies
• Microkernel/Modular Design: The project is segregated into modules (config, naming, raft, console, openapi, etc.) that interact through clearly defined APIs.
• Distributed Consensus: Raft protocol is employed to handle cluster coordination without an external database.
• API Gateway Pattern: Separate HTTP and gRPC endpoints facilitate protocol-specific client communications.
• Containerization/Deployment: Supporting Docker, docker-compose, and Helm K8s deployment indicates cloud-native and containerized design approaches.
• Use of Rust’s module system to enforce clean separation of concerns.
• Support for plugins or SDK integration points, as exemplified by the sdk‑examples directory.