MCPcopy Index your code
hub / github.com/aiyang-zh/zhenyi

github.com/aiyang-zh/zhenyi @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
1,812 symbols 8,207 edges 164 files 831 documented · 46%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

zhenyi

Distributed real-time applications (Actor engine)

Built on zhenyi-base (MIT); zhenyi is licensed under AGPL-3.0 + commercial dual license · long-lived connections · low latency

Tests Go Reference Go Report Card Go Version License

中文 · Documentation index · Xinchuang · Actions · zhenyi-base


Introduction

zhenyi builds on zhenyi-base with an Actor runtime, unified gateway (TCP/WebSocket/KCP), cross-process bus & discovery, metrics and tracing for long-lived connections and real-time backends. For the module map and architecture, see the documentation index (large tables are maintained there, not here). Under same-host benchmarking on 2 vCPU / 4 GiB, two measured profiles are validated: ~40k QPS over a 7-day steady run (P99 ~1-2ms) and ~166k QPS in a 1-hour high-pressure run; see the benchmark report.

Highlights

  • Actor runtime: service-level Actors, MPSC mailbox, Tick/RPC, goroutine pool; optional circuit breaking and rate limiting.
  • Unified gateway: zgate supports TCP / WebSocket / KCP, optional HTTP, TLS / GM-TLS, application-layer payload encryption.
  • Distributed: Etcd discovery, NATS cross-process bus, remote routing (including RendezvousHash).
  • Observability: Prometheus, health probes, tracing, monitoring snapshots; see Monitoring overview.
  • Continuous profiling (optional): zpyroscope, decoupled from zmetrics; see Monitoring overview section 4.
  • Performance: message pooling, refcounting and zero-copy-oriented hot paths (verify against source and benchmarks).
  • Xinchuang / domestic IT: build and run notes in Xinchuang.

Quick start

go test ./... -count=1
go run ./examples/im_single_demo
# Second terminal: go run ./examples/im_single_client

The single-process demo does not require Etcd/NATS; multi-process examples (e.g. im_multi_demo) need Etcd + NATS → Examples overview (including --reactor / --sharedSendWorker and mmo_web_demo).

Documentation

Doc Link
Full index (Support, security, monitoring, releases, etc.) DOCS_INDEX_EN.md
Beginner's guide BEGINNER_GUIDE_EN.md
Architecture ARCHITECTURE_EN.md
Module API MODULE_API_EN.md
Benchmark report BENCHMARK_EN.md
Xinchuang XINCHUANG_EN.md
Book (aligned with code) go-actor-realtime

License & compliance

AGPL-3.0 + commercial dual license. Open-source use must follow LICENSE. For commercial use, closed distribution, or network services to third parties, read COMMERCIAL_LICENSE_EN.md first.
Commercial contact: 1093993119@qq.com

Development & CI

make test           # unit tests
make release-check  # pre-release: doc links + tests, etc.

For more Make targets and benchmarks, see each Makefile and Examples.


This README is only an entry point; per-package docs live under each directory (README.md / README_EN.md), with a single hub at DOCS_INDEX_EN.
Some documentation may be drafted with AI assistance and reviewed by maintainers. The repo runs CI (tests, race, coverage, go vet, doc link checks, etc.—see .github/workflows). Legal terms: LICENSE. If docs and behavior disagree, defer to reproducible source and tests. Issues and PRs welcome.

Extension points exported contracts — how you extend this code

IScriptEngine (Interface)
IScriptEngine defines the unified scripting engine contract. IScriptEngine 脚本引擎统一接口。 It abstracts Lua, JavaScript, and S [8 …
zscript/interface.go
IScriptEngine (Interface)
IScriptEngine defines a unified script engine contract. IScriptEngine 脚本引擎接口(兼容所有引擎类型)。 Note: this is a simplified contr [8 …
ziface/igroup.go
IMessage (Interface)
IMessage defines VT serialization contract for business messages. IMessage 定义业务消息需实现的 VT 序列化契约。 [7 implementers]
ziface/imessage.go
TopicBus (Interface)
TopicBus abstracts topic-based cross-process message bus. TopicBus 基于 topic 的跨进程消息总线抽象。 - Broadcast: broadcast one mess [6 …
zbus/bus.go
RemoteRouteStrategy (Interface)
RemoteRouteStrategy selects the preferred candidate index from remote actors. RemoteRouteStrategy 负责从候选远程 Actor 中选出“首选候选 [4 …
zroute/remote_strategy.go
IMonitorable (Interface)
IMonitorable is the interface for monitorable components. IMonitorable 可监控的组件接口。 [4 implementers]
zmonitor/interface.go
Discoverer (Interface)
Discoverer defines service discovery contract for actor registration and lookup. Discoverer 定义服务发现契约:Actor 注册、查找与变更订阅。 [3 …
ziface/idiscovery.go
IServerActor (Interface)
IServerActor is for Actors requiring an explicit server start phase. IServerActor 仅用于需要显式“服务启动阶段”的 Actor。 普通纯逻辑 Actor 可以 [2 …
ziface/iactor.go

Core symbols most depended-on inside this repo

Errorf
called by 225
examples/im_single_demo_bench/main.go
Add
called by 187
zaoi/grid.go
String
called by 151
ztengo/engine.go
Release
called by 141
zmsg/msgpool.go
Load
called by 123
zconfig/config.go
Close
called by 117
ziface/iactor.go
GetMessage
called by 108
zmsg/msgpool.go
DefaultEngineConfig
called by 104
zscript/interface.go

Shape

Function 821
Method 791
Struct 152
Interface 29
FuncType 9
TypeAlias 8
Class 2

Languages

Go99%
TypeScript1%
Python1%

Modules by API surface

zgate/gate_coverage_test.go89 symbols
zactor/actor_extra_test.go75 symbols
zaoi/aoi_test.go55 symbols
zmetrics/metrics_test.go51 symbols
zscript/adapter/adapter.go40 symbols
zmsg/msg_test.go39 symbols
zgate/gate.go37 symbols
ziface/iactor.go36 symbols
zactor/actor_test.go36 symbols
zmonitor/interface.go34 symbols
zmetrics/metrics.go34 symbols
zjs/engine_test.go34 symbols

For agents

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

⬇ download graph artifact