Skip to content

feat(events): NATS subject + payload schemas as new submodule#46

Merged
hbrombeer merged 1 commit intomainfrom
feat/events-submodule
May 3, 2026
Merged

feat(events): NATS subject + payload schemas as new submodule#46
hbrombeer merged 1 commit intomainfrom
feat/events-submodule

Conversation

@hbrombeer
Copy link
Copy Markdown
Member

Summary

Adds a new events/ Gradle submodule alongside player/ and status/, holding proto3 schemas for NATS pub/sub event payloads + canonical subject patterns. Symmetric to the existing gRPC contracts but for async events.

First batch of 4 proto files:

File Message Subject
config_events.proto ConfigChanged config.{app}.{env}.changed
player_events.proto PlayerJoined / Left / Switched presence.player.{action}.{playerId}
friends_events.proto FriendStatusChanged friends.status.{recipientPlayerId}
match_events.proto MatchStarted / Ended match.lifecycle.{action}.{matchId}

Subject patterns live in doc-comments for now. Follow-up: generate a Subjects.kt object with typed subject(...) helpers so publishers don't hand-write subject strings.

Why

Existing service-config already publishes to NATS (ConfigChangePublisher.kt) but the subject + payload format lives only in that service's code. Same drift risk as if every gRPC service hand-rolled their proto. This module is the cross-language source-of-truth — proto consumers in Kotlin/Java/Go/TS all see the same shape.

Concept doc: https://grounds.atlassian.net/wiki/spaces/GK/pages/209715203

Test plan

  • ./gradlew :events:assemble succeeds
  • proto files lint as valid proto3
  • Once merged, service-config follow-up PR to migrate ConfigChangePublisher to use the generated ConfigChanged class

🤖 Generated with Claude Code

Symmetry with the existing player/ and status/ modules but for
asynchronous events flowing over NATS pub/sub instead of gRPC.
This is the canonical home for cross-service event contracts —
proto3 payload definitions plus subject patterns documented in
each message's leading comment.

First batch of 4 proto files:

  config_events.proto   ConfigChanged
                        Subject: config.{app}.{env}.changed
                        Existing pattern from service-config's
                        ConfigChangePublisher.kt — codifies it
                        cross-language.

  player_events.proto   PlayerJoined / PlayerLeft / PlayerSwitched
                        Subjects: presence.player.{joined,left,switched}.{playerId}
                        Cross-proxy presence — Velocity emits these
                        on session lifecycle.

  friends_events.proto  FriendStatusChanged
                        Subject: friends.status.{recipientPlayerId}
                        Per-recipient fan-out from service-social
                        whenever a friend's online state changes.
                        Subject scoped per recipient so each proxy
                        only sees traffic relevant to its locally-
                        connected players.

  match_events.proto    MatchStarted / MatchEnded
                        Subjects: match.lifecycle.{started,ended}.{matchId}
                        Minigame lifecycle for stats consumers.

Subject patterns live in doc-comments for now. Phase-2 extension:
generate a Subjects.kt object with typed subject(...) helpers so
publishers/subscribers don't hand-write subject strings.

Wired up:
  - settings.gradle.kts: new `events` subproject
  - release-please-config.json: events package added
  - .release-please-manifest.json: events at 0.0.0 — first feat:
    bump will land it at 0.1.0

Codegen: same pattern as player/status — proto files are resources
under src/main/proto/, downstream consumers run their own protoc.

Konzept-Doc: https://grounds.atlassian.net/wiki/spaces/GK/pages/209715203

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hbrombeer hbrombeer force-pushed the feat/events-submodule branch from 64bfdec to 66dd65b Compare May 3, 2026 17:57
@hbrombeer hbrombeer merged commit 59bc310 into main May 3, 2026
4 checks passed
@hbrombeer hbrombeer deleted the feat/events-submodule branch May 3, 2026 17:57
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