private void UpdateFixtureState(Fixture snapshot, bool isSnapshot = false) { _marketsRuleManager.CommitChanges(); var status = (MatchStatus)Enum.Parse(typeof(MatchStatus), snapshot.MatchStatus); var fixtureStateActor = Context.System.ActorSelection(FixtureStateActor.Path); var updateFixtureStateMsg = new UpdateFixtureStateMsg { FixtureId = _fixtureId, Sport = _resource.Sport, Status = status, Sequence = snapshot.Sequence, Epoch = snapshot.Epoch }; fixtureStateActor.Tell(updateFixtureStateMsg); if (isSnapshot) { _lastSequenceProcessedInSnapshot = snapshot.Sequence; } _currentSequence = snapshot.Sequence; _currentEpoch = snapshot.Epoch; }
private void UpdateFixtureStateMsgHandler(UpdateFixtureStateMsg msg) { _logger.Debug($"Updating state for Fixture fixtureId={msg.FixtureId} sequence={msg.Sequence}"); FixtureState fixtureState; if (!_fixturesState.TryGetValue(msg.FixtureId, out fixtureState)) { fixtureState = new FixtureState { Id = msg.FixtureId, Sport = msg.Sport }; } fixtureState.Sequence = msg.Sequence; fixtureState.MatchStatus = msg.Status; fixtureState.Epoch = msg.Epoch; _fixturesState[msg.FixtureId] = fixtureState; }
private void ProcessFixtureDelete(Fixture fixtureDelta) { _logger.Info( $"{_resource} has been deleted from the GTP Fixture Factory. Suspending all markets and stopping the stream."); Fixture fixtureDeleted = new Fixture { Id = _fixtureId, FixtureName = fixtureDelta.FixtureName, MatchStatus = ((int)MatchStatus.Deleted).ToString() }; if (_marketsRuleManager.CurrentState != null) { fixtureDeleted.Sequence = _marketsRuleManager.CurrentState.FixtureSequence; } try { SuspendFixture(SuspensionReason.FIXTURE_DELETED); try { _streamStatsActor.Tell(new UpdatePluginStatsStartMsg() { Fixture = fixtureDelta, Sequence = fixtureDelta.Sequence, IsSnapshot = false, UpdateReceivedAt = DateTime.UtcNow, PluginMethod = "ProcessFixtureDeletion" }); _platformConnector.ProcessFixtureDeletion(fixtureDeleted); _streamStatsActor.Tell(new UpdatePluginStatsFinishMsg { CompletedAt = DateTime.UtcNow }); } catch (Exception ex) { var pluginError = new PluginException($"Plugin ProcessFixtureDeletion {fixtureDeleted} error occured", ex); UpdateStatsError(pluginError); throw pluginError; } } catch (Exception e) { _logger.Error($"An exception occured while trying to process fixture deletion for {_resource}", e); throw; } //reset fixture state _marketsRuleManager.OnFixtureUnPublished(); var fixtureStateActor = Context.System.ActorSelection(FixtureStateActor.Path); var updateFixtureStateMsg = new UpdateFixtureStateMsg { FixtureId = _fixtureId, Sport = _resource.Sport, Status = MatchStatus.Deleted, Sequence = -1, Epoch = _currentEpoch }; fixtureStateActor.Tell(updateFixtureStateMsg); }