Пример #1
0
 private static bool NeedToInvalidateCache(BrokerSettingsChangedEvent e)
 {
     //invalidating cache only if fields related to assets changed
     //see CronutAssetExtensions.SetDividendFactorFields for details
     return(!e.NewValue.Dividends871MPercent.Equals(e.OldValue.Dividends871MPercent) ||
            !e.NewValue.DividendsLongPercent.Equals(e.OldValue.DividendsLongPercent) ||
            !e.NewValue.DividendsShortPercent.Equals(e.OldValue.DividendsShortPercent));
 }
        private Task HandleBrokerSettingsChangedEvent(BrokerSettingsChangedEvent @event)
        {
            if (@event.ChangeType == ChangeType.Edition && @event.NewValue.BrokerId == brokerId)
            {
                brokerSettingsCache.Update(@event.NewValue);
            }

            return(Task.CompletedTask);
        }
Пример #3
0
 public async Task Handle(BrokerSettingsChangedEvent e)
 {
     if (NeedToInvalidateCache(e))
     {
         _log.Info("Invalidating cache for all legacy assets", context: e);
         await _legacyAssetsCacheUpdater.UpdateAll(e.Timestamp);
     }
     else
     {
         _log.Info("Cache invalidation not required", context: e);
     }
 }
Пример #4
0
        public async Task Handle(BrokerSettingsChangedEvent e)
        {
            switch (e.ChangeType)
            {
            case ChangeType.Creation:
                break;

            case ChangeType.Edition:
                if (e.OldValue == null || IsScheduleDataChanged(e.OldValue, e.NewValue, _settings.BrokerId))
                {
                    await _scheduleSettingsCache.UpdateAllSettingsAsync();

                    _overnightMarginService.ScheduleNext();
                    _scheduleControlService.ScheduleNext();
                }
                break;

            case ChangeType.Deletion:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private async Task ProcessMessageAsync(BrokerSettingsChangedEvent message)
        {
            await _handler.Handle(message);

            _log.Info($"Handled event {nameof(BrokerSettingsChangedEvent)}. Event created at: {message.Timestamp.ToShortTimeString()}");
        }