e-cat is a Rust microservices framework benchmarked against go-kratos/kratos v3.
It provides an API-first development experience, a pluggable component architecture, a unified HTTP/gRPC middleware abstraction, and a full CLI toolchain. Developers already familiar with Kratos can get up to speed seamlessly, while taking full advantage of Rust’s type safety, zero-cost abstractions, and extreme performance.
API-first: Define APIs, error codes, and metadata in Protobuf; code generation via prost + tonic-build
Dual protocol support: HTTP (axum) and gRPC (tonic) share the same tower::Layer middleware
Pluggable architecture: Registry, Config, Logging, and Encoding are all abstracted behind traits, with production-ready implementations provided by default
Middleware system: Built-in Recovery, Tracing, Logging, Timeout, and Security; composed with tower::ServiceBuilder
Application lifecycle: Build an App with the Builder pattern, start multiple servers concurrently, handle SIGTERM/SIGINT, and hook into start/stop lifecycle events
Type safety: A protobuf-based error code system with compile-time HTTP status code mapping
Observability: tracing + opentelemetry + Prometheus out of the box
Attack detection: Automatically recognizes 27 attack patterns (SQL injection, XSS, SSRF, path traversal, etc.), logs an alert only, never blocks
Multiple data sources: RDBMS (SQLite/PG/MySQL/TiDB), cache, OLAP, search engine, graph database, time series database
Every data backend goes through a unified trait abstraction (RdbmsClient / Cache / SearchClient / GraphClient / TsdbClient); pull in the matching contrib crate as needed.
# scaffold a project ecat new helloworld cd helloworld
# add a proto definition ecat proto add api/helloworld/helloworld.proto
# generate client and server code ecat proto client api/helloworld/helloworld.proto ecat proto server api/helloworld/helloworld.proto -t internal/service
fnget_user(id: u64) ->Result<User, Error> { if id == 0 { returnErr(Error::new( ErrorCode::InvalidArgument, "bad_request", "user id must be positive", )); } // ... }
Reuse tower::Service, trait generics, and zero-cost abstractions; no “Go in Rust”
3
Type safety
Catch errors at compile time; every Protobuf definition is strongly typed
4
Pluggable
Registry, Config, Logging, and Encoding are all abstracted behind traits
5
Complete toolchain
The CLI covers project scaffolding, proto code generation, and dev runs
6
Performance first
Zero-cost abstractions + async runtime
7
Observable
tracing + OpenTelemetry + Prometheus out of the box
Technical Notes
Why tower::Service
tower::Service is the Rust async ecosystem’s equivalent of http.Handler. Both axum and tonic are built on tower, so e-cat needs no custom middleware trait — shipping tower::Layer implementations directly gives you the same effect as Kratos middleware, with zero adapter overhead.
Why a Cargo Workspace
It matches Kratos’s modular design. Every ecat-* crate is versioned and compiled independently, and users pull in only what they need. Core crates keep their dependencies minimal, while contrib crates provide optional integrations.
Why prost (and not protobuf-rs)
prost is the most widely used protobuf implementation in the Rust community; it generates type-safe code at compile time and integrates deeply with tonic.