Skip to content

feat(controller): assign region cells to instances - #57

Merged
TheMeinerLP merged 4 commits into
mainfrom
feat/v2-region-cells-main
Nov 25, 2026
Merged

TheMeinerLP merged 4 commits into
mainfrom
feat/v2-region-cells-main

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Contributor

Problem

A big world has to be served by more than one instance, but nothing knew which instance is responsible for which
part of the map. A proxy could not send a player to the right server for a position.

Approach

A pool can declare sharding with a static list of cells (name plus chunk bounds). The controller gives every
cell to exactly one Ready instance and keeps that assignment while the instance stays Ready. When an instance
fails or disappears its cells move to the Ready instance that serves the fewest. The assignment is stored as the
instance label grus.olf/cells and every change publishes pool.cells.

GET /v1/pools/{pool}/cells lists cell, bounds, instance and address; GET /v1/pools/{pool}/cells/at?x=&z=
takes block coordinates and answers with the owner (404 outside every cell, 409 while the cell has no Ready
instance). grus cells <pool> shows the table. The Velocity plugin gets /region <x> <z> (permission
grus.region), enabled by GRUS_SHARD_POOL; it connects the player to the owning server.

When an instance becomes Ready later and owns no cell while another one holds two or more, one cell (the last by
name) moves over, so a second instance picks up its share. Nothing else moves while the counts differ by at most
one. Splitting or merging cells with the load is spec only (comment in the model).

The CRD schema for sharding.cells changed from names to objects; the schema test covers it. OpenAPI and the
web types are regenerated (separate commit, only the generated types file).

Testing

Controller tests with a fake clock and fake driver (spread, stability, failover, removal, lookup), API, model,
client and CLI tests, and a Velocity unit test for URL building and answer parsing. :grus-velocity:test and
:grus-sdk:test pass.

A pool with a sharding section gets its cells spread over the Ready
instances, kept stable and moved when an instance fails. The cells API
resolves block coordinates to the owning instance. Adds grus cells.
/region <x> <z> asks the controller which instance owns the block
position in GRUS_SHARD_POOL and connects the player to it.
@TheMeinerLP
TheMeinerLP merged commit 82a3d5a into main Nov 25, 2026
8 checks passed
@TheMeinerLP
TheMeinerLP deleted the feat/v2-region-cells-main branch November 25, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant