fix(leaderboards): move match publication to a durable background queue - #42
Conversation
|
this would also solve #40 right? |
Skyaero42
left a comment
There was a problem hiding this comment.
Removing polly is the correct call here I think.
I'm pretty new to the code base and style, so I'm still struggling a bit. Overall this looks good.
One point of attention: the new code throws at a few points. I'm not entirely sure if the throw is properly caught. If it is not, the timer will not be restarted and cleaning up the lobbies will fail.
| { | ||
| Console.WriteLine($"[ERROR] DetermineLobbyWinnerIfNotPresent failed: {ex.Message}"); | ||
| SentrySdk.CaptureException(ex); | ||
| throw; |
There was a problem hiding this comment.
Not sure if you want to throw here.
Is it caught somewhere else?
Does it have to be thrown or can the application continue after it has been caught at this level?
Multiple times in this PR.
There was a problem hiding this comment.
This prevents the exception from being swallowed. It bubbles up to DeleteLobby, logs to Sentry, and returns false, so the lobby persists and the cleanup will retry.
1348d08 to
5a2aa5a
Compare
5a2aa5a to
f7e0b1e
Compare
| postToken = sectionPostToken; | ||
| } | ||
|
|
||
| private static void GetExternalLeaderboardsGetConfig(out string getUrl, out string getToken) |
There was a problem hiding this comment.
nit: name has 'get' twice. Recommend GetExternalLeaderboardsConfig
There was a problem hiding this comment.
I’ve renamed it :)
| } | ||
|
|
||
| // Persist publication before removing the lobby. | ||
| await Database.MatchHistory.FinalizeAndScheduleExternalPublication(db, lobby); |
There was a problem hiding this comment.
This can throw and is not caught. Is that intentional?
There was a problem hiding this comment.
It’s handled by DeleteLobby, which logs the error and leaves the lobby registered so the cleanup timer can retry it.
Signed-off-by: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
External leaderboard publication previously ran during lobby teardown on the WebSocket processing path. External HTTP latency and retries could therefore delay processing for connected users.
This change records publication work when a match is finalized and processes it asynchronously through a durable database-backed worker.
external_publication.Apply
upgrade_20260816_external_leaderboard_publication.sqlbefore deploying the updated service.The worker currently assumes a single service instance.