Skip to content

Rewrite in Go#21

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/rewrite-codebase-in-golang
Draft

Rewrite in Go#21
Copilot wants to merge 8 commits intomainfrom
copilot/rewrite-codebase-in-golang

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 8, 2026

Go channels only work within a single process. The existing implementation couldn't share game state across multiple server instances, unlike Elixir's distributed PubSub.

Changes

Redis pub/sub integration (internal/pubsub/)

  • Wrapper over redis/go-redis/v9 with graceful degradation
  • Subscribes to game:* channels for cross-server updates
  • Falls back to single-server mode if Redis unavailable

Hub modifications (internal/hub/hub.go)

  • Stores game state in Redis (game_state:{gameID} keys)
  • Publishes updates to Redis channels (game:{gameID})
  • Loads games from Redis if not in local memory
  • Forwards Redis messages to local WebSocket clients

Configuration (cmd/server/main.go)

  • Added -redis and -redis-password flags
  • Supports REDIS_URL and REDIS_PASSWORD env vars

Architecture

Server A                    Redis                    Server B
   |                          |                          |
   |-- Create game ---------> | (store game_state:ID)    |
   |                          |                          |
   |-- Player scores -------> | (publish game:ID) -----> |
   |                          |                          |
   |                      (subscribe game:*)             |
   |                          |                          |
   ↓                          ↓                          ↓
WebSocket clients      All servers sync        WebSocket clients

Usage

Single-server mode (default):

./bin/robot-race -addr :8080

Multi-server mode:

./bin/robot-race -addr :8080 -redis localhost:6379
./bin/robot-race -addr :8081 -redis localhost:6379

Players on different servers can now join and play in the same game instance.

Backward Compatibility

Fully backward compatible. Redis is optional - server runs in single-server mode without it. No breaking changes to existing code or APIs.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits February 8, 2026 18:30
Co-authored-by: nwjlyons <126417+nwjlyons@users.noreply.github.com>
Co-authored-by: nwjlyons <126417+nwjlyons@users.noreply.github.com>
…dated README

Co-authored-by: nwjlyons <126417+nwjlyons@users.noreply.github.com>
Co-authored-by: nwjlyons <126417+nwjlyons@users.noreply.github.com>
Co-authored-by: nwjlyons <126417+nwjlyons@users.noreply.github.com>
Copilot AI changed the title [WIP] Rewrite codebase in Golang for multiplayer functionality Rewrite game server in Go with multi-instance deployment support Feb 8, 2026
Copilot AI requested a review from nwjlyons February 8, 2026 18:38
Copilot AI and others added 2 commits February 8, 2026 18:57
Co-authored-by: nwjlyons <126417+nwjlyons@users.noreply.github.com>
Co-authored-by: nwjlyons <126417+nwjlyons@users.noreply.github.com>
Copilot AI changed the title Rewrite game server in Go with multi-instance deployment support Add Redis pub/sub for cross-server game state synchronization Feb 8, 2026
@nwjlyons nwjlyons changed the title Add Redis pub/sub for cross-server game state synchronization Rewrite in Go Feb 8, 2026
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.

2 participants