private void WriteMessageData(IOddsFeedSession session, IEventMessage <ISportEvent> message, DateTime messageUserReceived = default, double processingTotalMilliSeconds = 0)
        {
            var userStartProcessing = DateTime.Now;
            var sdkProcessingTime   = (userStartProcessing - Helper.FromEpochTime(message.Timestamps.Received)).TotalMilliseconds;
            var createdToUserTime   = (userStartProcessing - Helper.FromEpochTime(message.Timestamps.Created)).TotalMilliseconds;
            var pureSdkTime         = messageUserReceived == default
                ? sdkProcessingTime
                : (userStartProcessing - messageUserReceived).TotalMilliseconds;

            var messageName = message.GetType().Name;

            messageName = messageName.Substring(0, messageName.IndexOf("`", StringComparison.InvariantCultureIgnoreCase));
            var requestId       = message.RequestId.HasValue ? $", RequestId={message.RequestId}" : string.Empty;
            var producerMessage = $"[{message.Producer.Id}-{message.Producer.Name}|{Helper.ToEpochTime(message.Producer.LastTimestampBeforeDisconnect)}={message.Producer.LastTimestampBeforeDisconnect}|{!message.Producer.IsProducerDown}]";
            var processingTotalMilliSecondsStr = processingTotalMilliSeconds > 0 ? $", COMPLETED in {processingTotalMilliSeconds}ms" : string.Empty;
            var msg = $"{session.Name}: {messageName}:Producer={producerMessage}, GeneratedAt={message.Timestamps.Created}={Helper.FromEpochTime(message.Timestamps.Created)}, PureSdkProcessingTime={(int)pureSdkTime}ms, SdkProcessingTime={(int)sdkProcessingTime}ms, Behind={(int)createdToUserTime}ms, EventId={message.Event.Id}{requestId}{processingTotalMilliSecondsStr}.";

            Helper.WriteToOutput(msg);
            _log.LogInformation(msg);

            if (message.Timestamps.Sent == 0)
            {
                msg = $"Message {messageName} created {message.Timestamps.Created} on producer {message.Producer.Id}-{message.Producer.Name} does not have sent timestamp.";
                Helper.WriteToOutput(msg);
                _log.LogError(msg);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attaches to events raised by <see cref="IOddsFeedSession"/>
        /// </summary>
        /// <param name="session">A <see cref="IOddsFeedSession"/> instance </param>
        private void AttachToSessionHighEvents(IOddsFeedSession session)
        {
            Guard.Argument(session, nameof(session)).NotNull();

            _log.Info("Attaching to session (high) events");
            session.OnUnparsableMessageReceived += SessionHighOnUnparsableMessageReceived;
            session.OnBetCancel             += SessionHighOnBetCancel;
            session.OnBetSettlement         += SessionHighOnBetSettlement;
            session.OnBetStop               += SessionHighOnBetStop;
            session.OnFixtureChange         += SessionHighOnFixtureChange;
            session.OnOddsChange            += SessionHighOnOddsChange;
            session.OnRollbackBetCancel     += SessionHighOnRollbackBetCancel;
            session.OnRollbackBetSettlement += SessionHighOnRollbackBetSettlement;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Detaches from events defined by <see cref="IOddsFeedSession"/>
        /// </summary>
        /// <param name="session">A <see cref="IOddsFeedSession"/> instance</param>
        private void DetachFromSessionLowEvents(IOddsFeedSession session)
        {
            Guard.Argument(session, nameof(session)).NotNull();

            _log.Info("Detaching from session (low) events");
            session.OnUnparsableMessageReceived -= SessionLowOnUnparsableMessageReceived;
            session.OnBetCancel             -= SessionLowOnBetCancel;
            session.OnBetSettlement         -= SessionLowOnBetSettlement;
            session.OnBetStop               -= SessionLowOnBetStop;
            session.OnFixtureChange         -= SessionLowOnFixtureChange;
            session.OnOddsChange            -= SessionLowOnOddsChange;
            session.OnRollbackBetCancel     -= SessionLowOnRollbackBetCancel;
            session.OnRollbackBetSettlement -= SessionLowOnRollbackBetSettlement;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Detaches from events defined by <see cref="IOddsFeed"/>
        /// </summary>
        /// <param name="session">A <see cref="IOddsFeedSession"/> instance</param>
        private void DetachFromSessionEvents(IOddsFeedSession session)
        {
            Contract.Requires(session != null);

            _log.Info("Detaching from session events");
            session.OnUnparsableMessageReceived -= SessionOnUnparsableMessageReceived;
            session.OnBetCancel             -= SessionOnBetCancel;
            session.OnBetSettlement         -= SessionOnBetSettlement;
            session.OnBetStop               -= SessionOnBetStop;
            session.OnFixtureChange         -= SessionOnFixtureChange;
            session.OnOddsChange            -= SessionOnOddsChange;
            session.OnRollbackBetCancel     -= SessionOnRollbackBetCancel;
            session.OnRollbackBetSettlement -= SessionOnRollbackBetSettlement;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Attaches to events raised by <see cref="IOddsFeed"/>
        /// </summary>
        /// <param name="session">A <see cref="IOddsFeedSession"/> instance </param>
        private void AttachToSessionEvents(IOddsFeedSession session)
        {
            Contract.Requires(session != null);

            _log.Info("Attaching to session events");
            session.OnUnparsableMessageReceived += SessionOnUnparsableMessageReceived;
            session.OnBetCancel             += SessionOnBetCancel;
            session.OnBetSettlement         += SessionOnBetSettlement;
            session.OnBetStop               += SessionOnBetStop;
            session.OnFixtureChange         += SessionOnFixtureChange;
            session.OnOddsChange            += SessionOnOddsChange;
            session.OnRollbackBetCancel     += SessionOnRollbackBetCancel;
            session.OnRollbackBetSettlement += SessionOnRollbackBetSettlement;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Attaches to events raised by <see cref="IOddsFeedSession"/>
        /// </summary>
        /// <param name="session">A <see cref="IOddsFeedSession"/> instance </param>
        private void AttachToSessionHighEvents(IOddsFeedSession session)
        {
            Contract.Requires(session != null);

            Console.WriteLine("Attaching to session (high) events");
            session.OnUnparsableMessageReceived += SessionHighOnUnparsableMessageReceived;
            session.OnBetCancel             += SessionHighOnBetCancel;
            session.OnBetSettlement         += SessionHighOnBetSettlement;
            session.OnBetStop               += SessionHighOnBetStop;
            session.OnFixtureChange         += SessionHighOnFixtureChange;
            session.OnOddsChange            += SessionHighOnOddsChange;
            session.OnRollbackBetCancel     += SessionHighOnRollbackBetCancel;
            session.OnRollbackBetSettlement += SessionHighOnRollbackBetSettlement;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Detaches from events defined by <see cref="IOddsFeedSession"/>
        /// </summary>
        /// <param name="session">A <see cref="IOddsFeedSession"/> instance</param>
        private void DetachFromSessionLowEvents(IOddsFeedSession session)
        {
            Contract.Requires(session != null);

            Console.WriteLine("Detaching from session (low) events");
            session.OnUnparsableMessageReceived -= SessionLowOnUnparsableMessageReceived;
            session.OnBetCancel             -= SessionLowOnBetCancel;
            session.OnBetSettlement         -= SessionLowOnBetSettlement;
            session.OnBetStop               -= SessionLowOnBetStop;
            session.OnFixtureChange         -= SessionLowOnFixtureChange;
            session.OnOddsChange            -= SessionLowOnOddsChange;
            session.OnRollbackBetCancel     -= SessionLowOnRollbackBetCancel;
            session.OnRollbackBetSettlement -= SessionLowOnRollbackBetSettlement;
        }