Ecat
Ecat is a Rust microservices framework inspired by go-kratos/kratos() v3.
It provides an API-first development experience, pluggable component architecture, unified HTTP/gRPC middleware abstraction, and a complete CLI toolchain. Developers familiar with Kratos can get started immediately, while also leveraging Rust's type safety, zero-cost abstractions, and exceptional performance.
Architecture
┌──────────────────────────────────────────────────────────────┐
│ ecat-cli │
│ (new │ proto │ run │ build) │
├──────────────────────────────────────────────────────────────┤
│ ecat (App Lifecycle) │
│ AppBuilder → App { name, servers, hooks, ... } │
├────────────────────┬────────────────────┬────────────────────┤
│ transport │ middleware │ registry │
│ ───────── │ ────────── │ ──────── │
│ HTTP (axum) │ RecoveryLayer │ etcd │
│ gRPC (tonic) │ TracingLayer │ consul │
│ encoding │ LoggingLayer │ dns │
│ │ TimeoutLayer │ memory │
├────────────────────┼────────────────────┼────────────────────┤
│ config │ errors │ metadata │
│ ────── │ ────── │ ──────── │
│ file / env │ ErrorCode │ key-value │
│ remote source │ Error │ HTTP/gRPC │
├────────────────────┴────────────────────┴────────────────────┤
│ data layer │
│ ──────────────────────────────────────────────── │
│ rdbms: SQLite / PostgreSQL / MySQL / TiDB │
│ cache: Redis / Memcached │
│ olap: ClickHouse │
│ search: OpenSearch / Elasticsearch │
│ graph: Neo4j / NebulaGraph / ArangoDB │
│ tsdb: InfluxDB / Apache IoTDB / QuestDB │
├──────────────────────────────────────────────────────────────┤
│ ecat-protos │
│ (shared .proto definitions: errors, metadata, ...) │
└──────────────────────────────────────────────────────────────┘
Features
- API-first: Protobuf-defined APIs, error codes, and metadata
- Dual protocol: HTTP (axum) and gRPC (tonic) sharing one middleware chain
- Pluggable: Registry, Config, Logging, Encoding via trait abstractions
- Middleware: Built-in Recovery, Tracing, Logging, Timeout layers
- Lifecycle: Builder pattern, concurrent servers, graceful shutdown
- Type-safe: Protobuf-based error codes with compile-time HTTP mapping
- Observable: tracing + OpenTelemetry + Prometheus out of the box
Tech Stack
| Component | Choice |
|---|---|
| Runtime | tokio |
| HTTP | axum |
| gRPC | tonic |
| Protobuf | prost + tonic-build |
| Middleware | tower::Service / Layer |
| Tracing | tracing + opentelemetry-rust |
| Metrics | prometheus |
| Serialization | serde + prost |
| RDBMS | sqlx |
| CLI | clap |
Supported Databases
| Category | Database | Crate | Rust Driver |
|---|---|---|---|
| RDBMS | SQLite | ecat-data-sqlx |
sqlx |
| RDBMS | PostgreSQL | ecat-data-sqlx |
sqlx |
| RDBMS | MySQL | ecat-data-sqlx |
sqlx |
| RDBMS | TiDB | ecat-data-sqlx |
sqlx |
| Cache | Redis | ecat-data-redis |
redis-rs |
| Cache | Memcached | ecat-data-memcached |
memcache |
| OLAP | ClickHouse | ecat-data-clickhouse |
clickhouse-rs |
| Search | OpenSearch | ecat-data-opensearch |
opensearch |
| Search | Elasticsearch | ecat-data-elasticsearch |
elasticsearch |
| Graph | Neo4j | ecat-data-neo4j |
neo4j |
| Graph | NebulaGraph | ecat-data-nebulagraph |
nebula-client |
| Graph | ArangoDB | ecat-data-arangodb |
arangors |
| TSDB | InfluxDB | ecat-data-influxdb |
influxdb2 |
| TSDB | Apache IoTDB | ecat-data-iotdb |
iotdb-client-rs |
| TSDB | QuestDB | ecat-data-questdb |
questdb-rs (ILP) |
All backends share unified trait abstractions (
RdbmsClient/Cache/SearchClient/GraphClient/TsdbClient). Import the corresponding contrib crate as needed.
Quick Start
use ecat::App;
use ecat_transport_http::HttpServer;
use ecat_transport_grpc::GrpcServer;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let app = App::builder()
.name("my-service")
.version("v1.0.0")
.server(HttpServer::new(":8000"))
.server(GrpcServer::new(":9000"))
.build()?;
app.run().await?; // blocks until SIGTERM
Ok(())
}
Implementation Progress
| Phase | Status | Content |
|---|---|---|
| Phase 1 | Project skeleton, protos, errors, metadata, encoding, logging | |
| Phase 2 | Transport layer (HTTP + gRPC) | |
| Phase 3 | Middleware (Recovery/Tracing/Logging/Timeout) | |
| Phase 4 | App lifecycle management | |
| Phase 5 | Registry, Config, Metrics | |
| Phase 5.5 | Data access layer (traits + sqlx backend) | |
| Phase 6 | CLI toolchain (new/proto/run/build) | |
| Phase 7 | README, examples (helloworld), design docs |