feat(replay): add BattleContextStore for start->finish handoff

Bridges the start-time -> finish-time gap. /finish carries neither
battle_id nor opponent identity; this store holds both for the finish
handler to compose a ViewerBattleHistory row.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-10 07:38:37 -04:00
parent 0bb0f46abc
commit 869f9ce13d
4 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
namespace SVSim.Database.Services.Replay;
/// <summary>
/// In-memory per-viewer battle context store. Bridges the start-time → finish-time
/// gap: the /finish request body carries neither battle_id nor opponent identity,
/// so this stash holds everything the finish hook needs to compose a
/// ViewerBattleHistory row.
/// </summary>
public interface IBattleContextStore
{
/// <summary>Store the viewer's active battle context. Overwrites any prior entry.</summary>
void Set(long viewerId, BattleContext ctx);
/// <summary>Atomic read+clear. Returns null when no context (server restart,
/// non-tracked family, already taken). Finish handlers must tolerate null.</summary>
BattleContext? TakeFor(long viewerId);
}