feat(presence): count players by server across the network#24
Draft
hbrombeer wants to merge 1 commit into
Draft
Conversation
A proxy only knows the players connected to itself, so /agones reported "1 player" in a lobby that actually held two — the second player was on the other proxy. service-player holds the network-wide truth. Add countPlayersByServer() through the presence chain (gRPC client -> PlayerPresenceService -> PlayerSessionQueryImpl) so ProxyService can answer for the whole network instead of just this proxy. A failed or unavailable call returns null, never an empty result: empty means "nobody is online anywhere", null means "we could not ask", and callers must not conflate the two. Bumps library-grpc-contracts-player to 0.4.0 (adds the RPC) and plugin-proxy-api to 0.2.0 (adds the interface method + NetworkPlayerCounts).
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.
Why
Velocity can only count the players connected to the proxy that is asking. With
two proxies in front of one lobby,
/agonesreported "1 player" in a lobbythat actually held two — the second player was on the other proxy. service-player
holds the network-wide truth, so anything that states a number about the
network (
/agones, a server selector) has to ask it instead of countinglocally.
This adds
countPlayersByServer()through the presence chain soProxyServicecan answer for the whole network:Each layer mirrors the existing
getPlayerSession/resolvePlayerName/suggestNameslookups: same deadline handling, same fail-soft error handling.On a gRPC failure the method returns
null, never an emptyNetworkPlayerCounts— empty means "nobody is online anywhere", null means"we could not ask the network", and callers must not substitute proxy-local
numbers for either.
Status
This is step 4 of 5 in the cross-proxy player-count rollout, and is a
draft because it depends on two releases that have not shipped yet:
library-grpc-contracts-player0.4.0 (adds theCountPlayersByServerRPC) — feat(player): count online players per backend server library-grpc-contracts#71plugin-proxy-api0.2.0 (addsPlayerSessionQuery.countPlayersByServer()+NetworkPlayerCounts) — feat(proxy): expose network-wide player counts per backend server plugin-proxy#15Both dependency versions are already bumped in this PR and resolve
correctly (verified locally against
mavenLocal()), but GitHub Packagesdoes not have them published yet, so CI will not be able to resolve
dependencies until those two are released. This PR should stay in draft
until then.
Test plan
./gradlew build— BUILD SUCCESSFUL, all tests pass (verified locally with a temporarymavenLocal()repository, removed before commit)CountPlayersByServerReplywith two servers maps to the rightbyServermap and carriestotalthroughnullfromPlayerSessionQueryImpl.countPlayersByServer(), not an emptyNetworkPlayerCounts