vibecoded mcrouter in rust
rusty-mcrouteris meta protocol compatible only- why: meta wasn't a thing when mcrouter was first made, so it needed classic ascii plus facebook's private binary protocols to do leases, stale-while-revalidate, etc. meta is the open successor that does all of that with one flag-based command set.
- exact
/region/cluster/routing, regional/region/*/fanout and global/*/*/fanout are supported PrefixSelectorRouteselects policies by the longest prefix of the routing key--route-prefixchooses the default route;--send-invalid-route-to-defaultenables fallback for unmatched routing prefixes- see routing prefixes for config and execution details
- the config file is watched and reloaded without a restart; open client connections pick up the new routes on their next request
- a config that fails to parse or build is rejected and the running one kept;
rusty_mcrouter_config_last_reload_successfulsays whether the file on disk is live --reconfiguration-delay-mssets the poll period, and--disable-reload-configsturns reloading off- see config reload for what survives a reload and how failures are handled
bin/rusty-mcrouter/— the binary. cli, construct-and-wire startup, executor/thread ownership, signals, and supervision.crates/protocol/— the meta protocol codec: semantic request/reply types, frontend encoder/decoder, backend encoder/decodercrates/config/— parses mcrouter-style json/jsonc config (pools + routes).crates/observability-primitives/— std-onlyCounter,Gauge, andEventSink<T>shared by fact owners.crates/backend/— the backend leg: memcached client, destinations, health tracking, and backend metrics.crates/core/— routing: root prefix selection, pool hashing, failover and destination routes, built from config.crates/frontend/— the client-facing leg: listeners, complete protocol connections, request transport, and frontend metrics.crates/worker/— worker mailboxes, routing generations, socket distribution, and worker orchestration.crates/control/— control runtime, command mailboxes, config reload coordination, and reload-owned metrics/reporting.crates/observability/— event logging, metrics aggregation, and the/metricsendpoint.bench/— an isolated Cargo workspace and Python harness for benchmarking (seebench/README.md).docs/— design / architecture / mcrouter notes (seedocs/README.md)
the root Cargo.toml defines the application workspace and shared dependencies.
packages keep their rusty-mcrouter-* names; executable packages live in bin/
and libraries in crates/. each package uses the usual src/ and tests/ layout.
runtime construction uses explicit setup/resources: app-owned shared state and mailboxes flow into worker-local assembly, while actors expose construction and execution separately. frontend connections submit all routed requests through a concrete worker request sender and collect replies through their task sets; workers own routing execution and generation pinning. see dependency ownership.
cargo build --locked -p rusty-mcrouter
cargo test --workspace --locked
cargo test --manifest-path bench/Cargo.toml --workspace --locked