MCPcopy Index your code
hub / github.com/doyoubi/undermoon

github.com/doyoubi/undermoon @v0.6.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.2 ↗ · + Follow
1,703 symbols 5,372 edges 102 files 30 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

undermoon logo

Undermoon Continuous Integration

Undermoon is a self-managed Redis clustering system based on Redis Cluster Protocol supporting:

  • Horizontal scalability and high availability
  • Cluster management through HTTP API
  • Automatic failover for both master and replica
  • Fast scaling

Any storage system implementing redis protocol could also somehow work with undermoon, such as KeyDB.

For more in-depth explanation of Redis Cluster Protocol and how Undermoon implement it, please refer to Redis Cluster Protocol.

Architecture

architecture

Metadata Storage

Metadata storage stores all the metadata of the whole undermoon cluster, including existing Redis instances, proxies, and exposed Redis clusters. Now it's an in-memory storage server called Memory Broker. When using undermoon-operator, this Memory Broker will change to use ConfigMap to store the data.

Coordinator

Coordinator will synchronize the metadata between broker and server proxy. It also actively checks the liveness of server proxy and initiates failover.

Storage Cluster

The storage cluster consists of server proxies and Redis instances. It serves just like the official Redis Cluster to the applications. A Redis Cluster Proxy could be added between it and applications so that applications don't need to upgrade their Redis clients to smart clients.

Chunk

Chunk is the smallest building block of every single exposed Redis Cluster. Each chunk consists of 4 Redis instances and 2 server proxies evenly distributed in two different physical machines. So the node number of each Redis cluster will be the multiples of 4 with half masters and half replicas.

The design of chunk makes it very easy to build a cluster with a good topology for workload balancing.

Getting Started

Run Undermoon in Kubernetes

Using undermoon-operator is the easiest way to create Redis clusters if you have Kubernetes.

helm install my-undermoon-operator undermoon-operator-<x.x.x>.tgz

helm install \
    --set 'cluster.clusterName=my-cluster-name' \
    --set 'cluster.chunkNumber=2' \
    --set 'cluster.maxMemory=2048' \
    --set 'cluster.port=5299' \
    my-cluster \
    -n my-namespace \
    undermoon-cluster-<x.x.x>.tgz

See the README.md of undermoon-operator for how to use it.

Run Undermoon Using Docker Compose

See docker compose example.

Setup Undermoon Manually

Or you can set them up without docker following this docs: setting up undermoon manually.

Development

undermoon tries to avoid unsafe and some calls that could crash like unwrap.

Run the following commands before committing your codes:

$ make lint
$ make test

See more in the development guide.

Documentation

API

Extension points exported contracts — how you extend this code

EncodedPacket (Interface)
(no doc) [6 implementers]
src/protocol/packet.rs
CmdTaskSender (Interface)
(no doc) [8 implementers]
src/proxy/sender.rs
MetaStorage (Interface)
(no doc) [2 implementers]
src/broker/storage.rs
ProxiesRetriever (Interface)
(no doc) [2 implementers]
src/coordinator/core.rs
MasterReplicator (Interface)
(no doc) [1 implementers]
src/replication/replicator.rs
ThreadSafe (Interface)
(no doc) [1 implementers]
src/common/utils.rs
MigratingTask (Interface)
(no doc) [1 implementers]
src/migration/task.rs
ListCmdFunc (FuncType)
(no doc)
clienttest/golang/pkg/goredis_test.go

Core symbols most depended-on inside this repo

clone
called by 709
src/proxy/command.rs
to_string
called by 334
src/common/config.rs
map
called by 271
src/protocol/packet.rs
set_resp_result
called by 135
src/proxy/session.rs
get
called by 123
src/proxy/slot.rs
len
called by 95
src/protocol/client.rs
as_str
called by 88
src/common/cluster.rs
load
called by 49
src/common/biatomic.rs

Shape

Method 986
Function 371
Class 244
Interface 54
Enum 44
FuncType 2
Route 2

Languages

Rust92%
Python5%
Java2%
Go1%

Modules by API surface

src/broker/store.rs94 symbols
src/common/cluster.rs91 symbols
src/proxy/migration_backend.rs88 symbols
src/broker/service.rs83 symbols
src/proxy/cluster.rs50 symbols
src/proxy/backend.rs50 symbols
src/protocol/packet.rs44 symbols
src/proxy/command.rs42 symbols
src/proxy/blocking.rs42 symbols
chaostest/utils.py42 symbols
src/proxy/executor.rs41 symbols
src/broker/external.rs40 symbols

For agents

$ claude mcp add undermoon \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact