refactor(game): lock-free storage, remove /command, flatten engine wrapper #73
Reference in New Issue
Block a user
Delete Branch "feature/game-engine-refactor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refactor of the game-engine plumbing (game logic untouched), in three stages reviewed with the owner.
Stage 1 — lock-free persistence + admin serialisation. Removed the file lock from
repo/fs(the.lockfile, theRead/Write-vs-*Safeduality, the deadReadSafepolling);Writeis now a single atomic rename so concurrent reads are torn-free without a lock. The state-mutating admin writers (init/turn/banish) are serialised by one shared routerLimitMiddleware, rewritten to block on the request context instead of a racy shared 100 ms timer.Stage 2 — removed the obsolete immediate-command path end to end. Players submit through
PUT /api/v1/order; the legacyPUT /api/v1/commandpath is deleted across game (route, handler, 24 command factories,Ctrl), backend (Commandshandler/route,engineclient.ExecuteCommands), gateway (dispatch +executeUserGamesCommand+ routing entry), the FlatBuffers/model contract (UserGamesCommand[Response]) and transcoder, plus every affected OpenAPI/README/FUNCTIONAL/ARCHITECTURE doc. The integration proxy test is converted to the order path.Stage 3 — flattened the REST→engine wrapper. Replaced the executor adapter, the
controller.*package functions andRepoControllerwith one concretecontroller.Service; dropped the single-implementationRepoandStorageinterfaces (repo.Repo/fs.FSare now concrete). Handlers depend on a thinhandler.Engineseam and own the domain→REST projection; storage is resolved once at startup instead of per request.Net diff: +682 / −2805 across 65 files. All Go modules build and unit-test green locally; the integration suite runs here.