Exemplo n.º 1
0
        public async Task InvokeAll()
        {
            var migrationVersions = await _marginTradingBlobRepository.ReadAsync <Dictionary <string, int> >(
                LykkeConstants.MigrationsBlobContainer, "versions") ?? new Dictionary <string, int>();

            foreach (var migration in _migrations)
            {
                var migrationName = migration.GetType().Name;

                try
                {
                    if (!migrationVersions.TryGetValue(migrationName, out var version) ||
                        version < migration.Version)
                    {
                        await migration.Invoke();

                        migrationVersions.Remove(migrationName);
                        migrationVersions.Add(migrationName, migration.Version);
                    }
                }
                catch (Exception ex)
                {
                    await _log.WriteFatalErrorAsync(nameof(MigrationService), migrationName, ex, DateTime.UtcNow);
                }
            }

            await _marginTradingBlobRepository.Write(LykkeConstants.MigrationsBlobContainer, "versions", migrationVersions);
        }
Exemplo n.º 2
0
 public Task <IReadOnlyList <Order> > GetAllAsync()
 {
     return(_cacheProvider.GetAsync(nameof(OrdersSnapshotReaderService),
                                    async() => new CachableResult <IReadOnlyList <Order> >(
                                        (IReadOnlyList <Order>) await _blobRepository.ReadAsync <List <Order> >(
                                            LykkeConstants.StateBlobContainer, BlobName) ?? Array.Empty <Order>(),
                                        CachingParameters.FromSeconds(10))));
 }
 private Task <Dictionary <string, OrderBook> > GetOrderBookStateAsync()
 {
     return(_cacheProvider.GetAsync(nameof(OrderBookSnapshotReaderService),
                                    async() =>
     {
         var orderbookState = await _blobRepository.ReadAsync <Dictionary <string, OrderBook> >(
             LykkeConstants.StateBlobContainer, BlobName) ??
                              new Dictionary <string, OrderBook>();
         return new CachableResult <Dictionary <string, OrderBook> >(orderbookState,
                                                                     CachingParameters.FromSeconds(10));
     }));
 }
Exemplo n.º 4
0
 public async Task <IReadOnlyCollection <RawMessage> > LoadAsync(string exchangeName)
 {
     return(await _blobRepository.ReadAsync <List <RawMessage> >(BlobContainer, exchangeName));
 }