Go Framework (atsf4g-go)
The Go server framework atsf4g-go is still under active development, so this page summarizes only its architecture, repository layout, and current transport benchmark baseline. Its communication bus libatbus-go is completed and has a full protocol-stack benchmark report (see libatbus-go Benchmark).
Repositories and Component Status
atsf4g-go mirrors the layered layout of C++ atsf4g-co, using a single Go 1.27+ root module with go.work linking standalone library submodules:
| Repository | C++ Counterpart | Responsibility | Status |
|---|---|---|---|
| atsf4g-go | atsf4g-co | Main game server framework: shared components (src/component/), sample lobby service (src/lobbysvr/), Mako templates, and go tool dev pure-Go build tooling | In progress |
| libatbus-go | libatbus | Inter-server communication bus: full v2 protocol stack, X25519 key exchange, encryption, compression, and topology routing | Completed (Benchmark) |
| libatapp-go | libatapp | Application container: process lifecycle, module management, configuration, signal handling, and built-in ants worker pool | In progress |
| atframe-utils-go | atframe_utils | Base utilities: logging, algorithms, crypto/compression adapters, protoc-gen-mutable, and buildkit | In progress |
Excel configuration conversion reuses xresloader and xres-code-generator.
Design Shared with the C++ Framework
atsf4g-go shares the same communication protocol and development conventions as atsf4g-co, allowing Go and C++ services to coexist in the same cluster:
- Same communication stack:
libatbus-goimplements the same v2 framing, handshake, encryption, compression, and routing semantics as C++libatbus, so Go services connect throughatgateway/atproxyand interoperate with C++ services. - Same application and task abstractions: retains the
libatappmodule lifecycle,Dispatcher/TaskManager/TaskActiondispatch model, router object cache (RouterObjectBase), and Redis data layer. - Same declarative code generation: drives config loaders, database APIs, RPC handler registration, and downstream push APIs from Protobuf and Excel using Mako templates,
protoc-gen-mutable, andxresloader.
ActorExecutor and Token Scheduling
C++ atsf4g-co runs business coroutines on a single-threaded libuv event loop, keeping per-object state access naturally serialized within a process. The Go runtime schedules goroutines across multiple OS threads, and libatapp-go dispatches tasks concurrently through a built-in ants worker pool (AppInstance.PushAction). Running multiple tasks for the same stateful entity (such as the same player) directly on the worker pool would cause data races.
To reconcile Go's multi-threaded worker pool with lock-free per-entity business logic, atsf4g-go introduces ActorExecutor and a running-token mechanism in src/component/dispatcher/:
- Multi-threaded parallelism across
ActorExecutors: each stateful object (such as aRouterObjectBaseor playerUser) owns an independentActorExecutor. Distinct actors hold separate tokens and are scheduled concurrently onto multiple worker goroutines and OS threads bylibatapp-go's worker pool. - Serialized state access with multi-task I/O concurrency inside one
ActorExecutor: within a singleActorExecutor, a token (currentRunningLockandcurrentRunningAction) ensures at most oneTaskActionmutates that actor's state at any moment. When a task awaits an RPC, database query, or timer (YieldTaskAction), it sets up its await channel and releases the token before blocking, re-triggering actor scheduling so other queued tasks for the sameActorExecutorcan execute concurrently during the I/O wait. Once the reply or timeout arrives, the woken task re-acquires the token before resuming.
Three additional guardrails apply in the implementation:
- Runtime ownership check: mutations to router objects or player data validate the bound actor via
ActorExecutor.CheckActorExecutor(ctx)to catch cross-actor access bugs. - Queue and turn bounds: each
ActorExecutorcaps queued tasks atactor_max_pending_count(returningEN_ERR_ACTOR_MAX_PENDING_COUNTwhen exceeded) and limits actions processed per worker turn toactor_max_loop_countso one hot actor cannot starve a worker. - Actorless tasks: stateless global or system tasks can opt in via
AllowNoActor()and run directly onAppInstance.PushAction.
Transport Baseline and Ongoing Work
The completed libatbus-go library was benchmarked with the full protocol stack on the same dedicated Linux host as C++ libatbus: unencrypted, uncompressed single-pair TCP reaches 919.2K msg/s (200 B) and 1.91 GB/s (300 KB), and 1000-node fan-in sustains 1.14M msg/s (200 B) and 2.43 GB/s (300 KB). See libatbus-go Benchmark for cross-platform numbers, single-core and CPU-normalized comparisons with C++, GC and memory tuning, and cipher/compression tradeoffs.
libatapp-go connectors, service discovery, routing policies, and atsf4g-go business services remain under active development; see the atsf4g-go repository README for current build and development commands.