feat(presence)!: talk to service-player over HTTP - #33
Merged
Conversation
service-player publishes a REST API under /v1/players (service-player#99) and keeps its gRPC contract only until its callers move. This is one of the two. The client drops gRPC for the JDK's HttpClient and Jackson — the pair ForgeLinkClient already uses, so nothing new lands in the shaded jar and grpc-netty-shaded leaves it. Protobuf types no longer cross into the plugin either: presence now speaks its own small models, which is what lets the login outcome be a sealed result instead of a status enum the listener had to re-interpret. One behavioural difference worth naming: a login the service could not answer is Unavailable rather than a reply with an error status, so the proxy denies with "service unavailable" instead of the generic message. It could not ask, and saying so is more useful than implying the player did something wrong. BREAKING CHANGE: PLAYER_PRESENCE_GRPC_TARGET is replaced by PLAYER_SERVICE_URL. The deploy must set it in the same change that ships this jar; a proxy without it fails at startup rather than at the first login.
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.
service-player now publishes a REST API under
/v1/players(service-player#99, released as v0.9.0 and documented in the reference). It keeps its gRPC contract only until its callers move; this is one of the two.What changes
GrpcPlayerPresenceClient→HttpPlayerPresenceClient, using the JDK'sHttpClientand Jackson — the pairForgeLinkClientalready uses, so nothing new lands in the shaded jar andgrpc-netty-shadedleaves it.commondrops the protobuf contract and moves fromgrpc-conventionstokotlin-conventions.Protobuf types no longer cross into the plugin. Presence speaks its own models (
PlayerSessionInfo,PlayerLoginResult,PlayerLogoutResult, …), which is what lets the login outcome be a sealed result rather than a status enumPlayerConnectionListenerhad to re-interpret —handleSuccessand itsLoginStatuswhenare gone.TryPlayerLoginPOST /v1/players/sessions— 201 accepted, 409 already onlinePlayerLogoutDELETE /v1/players/{id}/session?proxyId=PlayerHeartbeatBatchPOST /v1/players/sessions/heartbeatsGetPlayerSessionGET /v1/players/{id}/sessionResolvePlayerNameGET /v1/players/sessions?name=UpdatePlayerServerPUT /v1/players/{id}/session/serverSuggestPlayerNamesGET /v1/players/names/suggestionsCountPlayersBy{Server,Proxy}GET /v1/players/counts/{servers,proxies}Get/SetPlayerLocaleGET/PUT /v1/players/{id}/localeBehaviour
Unchanged where it matters: nothing throws, every lookup still resolves a failure into "unknown" so an exception never reaches Velocity's event loop, the 2s deadline is kept, and logout stays scoped to the calling proxy so it cannot undo a transfer.
One difference worth naming: a login the service could not answer is now
Unavailablerather than a reply carrying an error status, so the proxy denies with the service unavailable message instead of the generic one. It could not ask — saying so beats implying the player did something wrong.Breaking
PLAYER_PRESENCE_GRPC_TARGET→PLAYER_SERVICE_URL. The scheme may be omitted, matching how the deploy sets the other service URLs. A proxy without it fails at startup rather than at the first login, so the deploy must set it in the same change that ships this jar.Verification
./gradlew spotlessCheck build— 32 tests, 0 failures. The client's 17 cover the status-code mapping (201/409/400/5xx), an unreachable service, absent fields, the proxy-scoped logout, and the token header, against a real loopback HTTP server.