public static IQueueExt Create(IReloadingManager <string> connectionStringManager, string queueName, TimeSpan?maxExecutionTimeout = null) { return(new ReloadingConnectionStringOnFailureAzureQueueDecorator( #pragma warning disable 618 async() => new AzureQueueExt(await connectionStringManager.Reload(), queueName, maxExecutionTimeout) #pragma warning restore 618 )); }
public static IQueueExt Create(IReloadingManager <string> connectionStringManager, string queueName, TimeSpan?maxExecutionTimeout = null) { queueName = queueName.ToLower(); NameValidator.ValidateQueueName(queueName); return(new ReloadingConnectionStringOnFailureAzureQueueDecorator( async(bool reload) => new AzureQueueExt( reload ? await connectionStringManager.Reload() : connectionStringManager.CurrentValue, queueName, maxExecutionTimeout) )); }
protected override async Task <T> Load() { if (TryGetActualRootValue(out var actualRootValue)) { var actualValue = _expr(actualRootValue); if (!_equal(actualValue, _current)) { return(_current = actualValue); } } return(_current = _expr(await _rootManager.Reload())); }
/// <summary> /// Creates <see cref="AzureBlobStorage"/> with automatically connection string reloading and auto-retries /// </summary> /// <param name="connectionStringManager">Connection string reloading manager</param> /// <param name="maxExecutionTimeout">Max execution timeout</param> /// <param name="onModificationRetryCount">Retries count for write operations</param> /// <param name="onGettingRetryCount">Retries count for read operations</param> /// <param name="retryDelay">Delay before next retry. Default value is 200 milliseconds</param> public static IBlobStorage Create( IReloadingManager <string> connectionStringManager, TimeSpan?maxExecutionTimeout = null, int onModificationRetryCount = 10, int onGettingRetryCount = 10, TimeSpan?retryDelay = null) { return(new RetryOnFailureAzureBlobDecorator( new ReloadingConnectionStringOnFailureAzureBlobDecorator( async() => new AzureBlobStorage(await connectionStringManager.Reload(), maxExecutionTimeout) ), onModificationRetryCount, onGettingRetryCount, retryDelay)); }
private static async Task <IDistributedLock> CreateAsync( IReloadingManager <string> connectionStringManager, bool reloadConnectionString, string container, string key, int lockDuration) { var @lock = new AzureBlobLock ( reloadConnectionString ? await connectionStringManager.Reload() : connectionStringManager.CurrentValue, container, key, lockDuration ); await @lock.InitializeAsync(); return(@lock); }
protected override void Load(ContainerBuilder builder) { builder .Register(ctx => new BlockchainWrapper( async() => (await _blockchainSettings.Reload()).TransactionNodeUrlList, _blockchainSettings.CurrentValue.TokenContractAddress, _blockchainSettings.CurrentValue.PrivateBlockchainGatewayContractAddress, _blockchainSettings.CurrentValue.WebSocketsConnectionTimeOut, ctx.Resolve <IHttpClientFactory>(), ctx.Resolve <ILogFactory>())) .As <IBlockchain>() .As <IStartable>() .SingleInstance(); var blockchainSettingsValue = _blockchainSettings.CurrentValue; builder .Register(ctx => new BuildCustomerWalletCreationTransactionStrategy ( blockchainSettingsValue.CustomerRegistryAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); builder .Register(ctx => new BuildBonusRewardTransactionStrategy ( blockchainSettingsValue.TokenContractAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); builder .Register(ctx => new BuildTransactionStrategy()) .As <IBuildTransactionStrategy>() .SingleInstance(); builder .Register(ctx => new BuildTransferStrategy ( blockchainSettingsValue.TokenContractAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); builder .Register(ctx => new BuildWalletLinkingTransactionStrategy ( blockchainSettingsValue.PrivateBlockchainGatewayContractAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); builder .Register(ctx => new BuildWalletUnlinkingTransactionStrategy ( blockchainSettingsValue.PrivateBlockchainGatewayContractAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); //We are using TokenContractAddress cause this strategy requires transfer to a specific address. builder .Register(ctx => new BuildTransferToExternalTransactionStrategy ( blockchainSettingsValue.TokenContractAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); builder .Register(ctx => new BuildTransferToInternalTransactionStrategy ( blockchainSettingsValue.PrivateBlockchainGatewayContractAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); builder .Register(ctx => new BuildSetTransferToPublicNetworkFeeStrategy ( blockchainSettingsValue.PrivateBlockchainGatewayContractAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); builder .Register(ctx => new BuildSeizeToInternalStrategy ( blockchainSettingsValue.TokenContractAddress )) .As <IBuildTransactionStrategy>() .SingleInstance(); }
public override async Task Execute() { await _appSettings.Reload(); Mode = _getMode(_appSettings.CurrentValue); }
private async Task FindTables() { await _dbsettings.Reload(); _log.Info($"Begin find log tables, count accounts: {_dbsettings.CurrentValue.ScanLogsConnString.Length}"); foreach (var connString in _dbsettings.CurrentValue.ScanLogsConnString) { var account = CloudStorageAccount.Parse(connString); var accountName = account.Credentials.AccountName; try { _log.Info($"Start scan account: {accountName}", context: accountName); var tableClient = account.CreateCloudTableClient(); var names = (await tableClient.ListTablesSegmentedAsync(null)).Select(e => e.Name) .Where(x => x.ToLower().Contains("log")) .Where(e => !_exclude.Contains(e)).ToArray(); _log.Info($"Find {names.Length} tables in subscribtion", context: accountName); var countAdd = 0; #if DEBUG var countHandling = 0; #endif foreach (var name in names) { try { var table = tableClient.GetTableReference(name); var operationGet = new TableQuery <LogEntity>().Take(1); var row = (await table.ExecuteQuerySegmentedAsync(operationGet, null)).FirstOrDefault(); if (row != null && row.DateTime != DateTime.MinValue && row.Level != null && (row.Msg != null || row.Stack != null)) { if (_tables.All(e => e.Name != name || e.ConnString != connString)) { var info = new TableInfo { Entity = AzureTableStorage <LogEntity> .Create(new FakeReloadingManager(connString), name, _logFactory), PartitionKey = DateTimeOffset.UtcNow.ToString("yyyy-MM-dd"), LastRowKey = DateTime.UtcNow.ToString("HH:mm:ss.fffffff"), Name = name, Account = accountName, ConnString = connString }; _tables.Add(info); countAdd++; } } #if DEBUG countHandling++; Console.Write($"\rhandling: {countHandling} / {names.Length} "); #endif } catch (Exception ex) { #if DEBUG Console.WriteLine(); #endif _log.Error(ex, context: $"{accountName} - {name}"); } } #if DEBUG Console.WriteLine(); #endif _log.Info($"Add {countAdd} tables to handling", context: accountName); } catch (Exception ex) { _log.Error(ex, context: $"{accountName}"); } } _log.Info($"Start handling {_tables.Count} tables"); }
protected override void Load(ContainerBuilder builder) { builder .RegisterEventPublishingService <CustomerRegisteredInBlockchainEvent>(_publisherSettings); builder .RegisterEventPublishingService <TransactionFailedInBlockchainEvent>(_publisherSettings); builder .RegisterEventPublishingService <MintEvent>(_publisherSettings); builder .RegisterEventPublishingService <TransferEvent>(_publisherSettings); builder .RegisterEventPublishingService <TransactionCompletedInBlockchainEvent>(_publisherSettings); builder .RegisterEventPublishingService <UndecodedEvent>(_publisherSettings); builder .RegisterEventPublishingService <StakeIncreasedEvent>(_publisherSettings); builder .RegisterEventPublishingService <StakeReleasedEvent>(_publisherSettings); builder .RegisterEventPublishingService <FeeCollectedEvent>(_publisherSettings); builder .RegisterEventPublishingService <SeizedFromEvent>(_publisherSettings); var blockchainSettings = _blockchainSettings.CurrentValue; builder .Register(ctx => new BlockchainIndexingService ( ctx.ResolveEventPublishingService <CustomerRegisteredInBlockchainEvent>(), ctx.ResolveEventPublishingService <MintEvent>(), ctx.ResolveEventPublishingService <TransferEvent>(), ctx.Resolve <IIndexingStateRepository>(), ctx.Resolve <ILogFactory>(), ctx.ResolveEventPublishingService <TransactionFailedInBlockchainEvent>(), ctx.ResolveEventPublishingService <TransactionCompletedInBlockchainEvent>(), ctx.ResolveEventPublishingService <UndecodedEvent>(), ctx.ResolveEventPublishingService <StakeIncreasedEvent>(), ctx.ResolveEventPublishingService <StakeReleasedEvent>(), ctx.ResolveEventPublishingService <FeeCollectedEvent>(), ctx.ResolveEventPublishingService <SeizedFromEvent>(), ctx.Resolve <IEthNodeClient>(), new [] { blockchainSettings.ContractAddresses.CustomerRegistry, blockchainSettings.ContractAddresses.PartnersPayments, blockchainSettings.ContractAddresses.PaymentTransfers, blockchainSettings.ContractAddresses.RoleRegistry, blockchainSettings.ContractAddresses.Token, blockchainSettings.ContractAddresses.Gateway, blockchainSettings.ContractAddresses.MVNVouchersPayments } )) .As <IBlockchainIndexingService>() .SingleInstance(); builder .Register(ctx => new IndexingService ( ctx.Resolve <IBlockchainIndexingService>(), ctx.Resolve <ILogFactory>(), blockchainSettings.IdleTime )) .AsSelf() .SingleInstance(); builder .Register(ctx => new EthNodeClient( async() => (await _blockchainSettings.Reload()).TransactionNodeUrlList, ctx.Resolve <ILogFactory>(), blockchainSettings.WebSocketsConnectionTimeOut, blockchainSettings.BatchSize)) .As <IEthNodeClient>() .SingleInstance(); builder .Register(ctx => new StartupManager ( ctx.ResolveEventPublishingService <CustomerRegisteredInBlockchainEvent>(), ctx.Resolve <IndexingService>(), ctx.Resolve <BlocksLagWatcher>(), ctx.Resolve <ILogFactory>(), ctx.ResolveEventPublishingService <TransactionFailedInBlockchainEvent>(), ctx.ResolveEventPublishingService <MintEvent>(), ctx.ResolveEventPublishingService <TransferEvent>(), ctx.ResolveEventPublishingService <UndecodedEvent>(), ctx.ResolveEventPublishingService <TransactionCompletedInBlockchainEvent>(), ctx.ResolveEventPublishingService <StakeIncreasedEvent>(), ctx.ResolveEventPublishingService <StakeReleasedEvent>(), ctx.ResolveEventPublishingService <FeeCollectedEvent>(), ctx.ResolveEventPublishingService <SeizedFromEvent>() )) .As <IStartupManager>() .SingleInstance(); builder .Register(ctx => new ShutdownManager ( ctx.ResolveEventPublishingService <CustomerRegisteredInBlockchainEvent>(), ctx.Resolve <IndexingService>(), ctx.Resolve <BlocksLagWatcher>(), ctx.Resolve <ILogFactory>(), ctx.ResolveEventPublishingService <TransactionFailedInBlockchainEvent>(), ctx.ResolveEventPublishingService <MintEvent>(), ctx.ResolveEventPublishingService <TransferEvent>(), ctx.ResolveEventPublishingService <UndecodedEvent>(), ctx.ResolveEventPublishingService <TransactionCompletedInBlockchainEvent>(), ctx.ResolveEventPublishingService <StakeIncreasedEvent>(), ctx.ResolveEventPublishingService <StakeReleasedEvent>(), ctx.ResolveEventPublishingService <FeeCollectedEvent>(), ctx.ResolveEventPublishingService <SeizedFromEvent>() )) .As <IShutdownManager>() .SingleInstance(); builder .Register(ctx => new BlocksLagWatcher( ctx.Resolve <ILogFactory>(), ctx.Resolve <IBlockchainIndexingService>(), blockchainSettings.WarningScanGapInBlocks, blockchainSettings.ErrorScanGapInBlocks)) .AsSelf() .SingleInstance(); }