feat(events): NATS subject + payload schemas as new submodule#46
Merged
feat(events): NATS subject + payload schemas as new submodule#46
Conversation
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>
64bfdec to
66dd65b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
events/Gradle submodule alongsideplayer/andstatus/, 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:
config_events.protoConfigChangedconfig.{app}.{env}.changedplayer_events.protoPlayerJoined / Left / Switchedpresence.player.{action}.{playerId}friends_events.protoFriendStatusChangedfriends.status.{recipientPlayerId}match_events.protoMatchStarted / Endedmatch.lifecycle.{action}.{matchId}Subject patterns live in doc-comments for now. Follow-up: generate a
Subjects.ktobject with typedsubject(...)helpers so publishers don't hand-write subject strings.Why
Existing
service-configalready 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:assemblesucceedsservice-configfollow-up PR to migrateConfigChangePublisherto use the generatedConfigChangedclass🤖 Generated with Claude Code