Skip to content

feat(presence): count players by server across the network#24

Draft
hbrombeer wants to merge 1 commit into
mainfrom
feat/count-players-by-server
Draft

feat(presence): count players by server across the network#24
hbrombeer wants to merge 1 commit into
mainfrom
feat/count-players-by-server

Conversation

@hbrombeer

Copy link
Copy Markdown
Member

Why

Velocity can only count the players connected to the proxy that is asking. With
two proxies in front of one lobby, /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, so anything that states a number about the
network (/agones, a server selector) has to ask it instead of counting
locally.

This adds countPlayersByServer() through the presence chain so
ProxyService can answer for the whole network:

GrpcPlayerPresenceClient.countPlayersByServer()  (common, raw gRPC call)
  -> PlayerPresenceService.countPlayersByServer() (velocity, wrapper)
    -> PlayerSessionQueryImpl.countPlayersByServer() (velocity, implements plugin-proxy's PlayerSessionQuery)

Each layer mirrors the existing getPlayerSession / resolvePlayerName /
suggestNames lookups: same deadline handling, same fail-soft error handling.
On a gRPC failure the method returns null, never an empty
NetworkPlayerCounts
— 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:

Both dependency versions are already bumped in this PR and resolve
correctly (verified locally against mavenLocal()), but GitHub Packages
does 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 temporary mavenLocal() repository, removed before commit)
  • New test: a CountPlayersByServerReply with two servers maps to the right byServer map and carries total through
  • New test: an unreachable/unavailable presence service yields null from PlayerSessionQueryImpl.countPlayersByServer(), not an empty NetworkPlayerCounts

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).
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