public static void RemoveLast(string matchId) { // Remove EventRepository.RemoveMostRecent(matchId); // Sync up with read model var match = Replay(matchId); if (match == null) { MatchSynchronizer.Clear(matchId); } else { MatchSynchronizer.Save(match); } // Further compensation logic here ... // ... }
public static void Log(string matchId, EventType eventOccurred, TeamId teamIndex, String team1 = null, String team2 = null, int?playerId = null) { var matchEvent = EventBuilder.New(matchId, eventOccurred, teamIndex, team1, team2, playerId); EventRepository.Store(matchEvent); // Sync up with read model // 1: read all events // 2: play all events using Match class // 3: save state to relational DB for reads/live var match = Replay(matchId); MatchSynchronizer.Save(match); // or // 1: do nothing here // 2: expect a scheduled job do previous sync steps // or // 1: do nothing here // 2: expect read stack replays events via Match class when requested }
public EventSourceManager(EventRepository eventRepository, MatchSynchronizer matchSynchronizer) { _eventRepository = eventRepository; _matchSynchronizer = matchSynchronizer; }