protected virtual ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <TApplicationSettings> settings, CurrentApplicationInfo applicationInfo, CorrelationContextAccessor correlationContextAccessor) { var logTableName = ApplicationName + applicationInfo.EnvInfo + "Log"; var aggregateLogger = new AggregateLogger(); var consoleLogger = new LogToConsole(); aggregateLogger.AddLog(consoleLogger); #region Logs settings validation if (!settings.CurrentValue.MtBrokersLogs.UseSerilog && string.IsNullOrWhiteSpace(settings.CurrentValue.MtBrokersLogs.LogsConnString)) { throw new Exception("Either UseSerilog must be true or LogsConnString must be set"); } #endregion Logs settings validation #region Slack registration IMtSlackNotificationsSender slackService = null; if (settings.CurrentValue.SlackNotifications != null) { var azureQueue = new AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }; var commonSlackService = services.UseSlackNotificationsSenderViaAzureQueue(azureQueue, consoleLogger); slackService = new MtSlackNotificationsSender(commonSlackService, ApplicationName, Environment.EnvironmentName); } else { slackService = new MtSlackNotificationsSenderLogStub(ApplicationName, Environment.EnvironmentName, consoleLogger); } services.AddSingleton <ISlackNotificationsSender>(slackService); services.AddSingleton <IMtSlackNotificationsSender>(slackService); #endregion Slack registration if (settings.CurrentValue.MtBrokersLogs.UseSerilog) { aggregateLogger.AddLog(new SerilogLogger(applicationInfo.GetType().Assembly, Configuration, new List <ILogEventEnricher> { new CorrelationLogEventEnricher("CorrelationId", correlationContextAccessor) })); } else if (settings.CurrentValue.MtBrokersLogs.StorageMode == StorageMode.SqlServer) { aggregateLogger.AddLog(new LogToSql(new SqlLogRepository(logTableName, settings.CurrentValue.MtBrokersLogs.LogsConnString))); } else if (settings.CurrentValue.MtBrokersLogs.StorageMode == StorageMode.Azure) { var dbLogConnectionStringManager = settings.Nested(x => x.MtBrokersLogs.LogsConnString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; if (string.IsNullOrEmpty(dbLogConnectionString)) { consoleLogger.WriteWarningAsync(ApplicationName, nameof(CreateLogWithSlack), "Table logger is not initialized").Wait(); return(aggregateLogger); } if (dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}")) { throw new InvalidOperationException($"LogsConnString {dbLogConnectionString} is not filled in settings"); } // Creating azure storage logger, which logs own messages to console log var azureStorageLogger = services.UseLogToAzureStorage(settings.Nested(s => s.MtBrokersLogs.LogsConnString), slackService, logTableName, consoleLogger); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); } return(aggregateLogger); }
public ExternalOrderReportAzureRepository(IReloadingManager <Settings.AppSettings> settings, ILog log) { _tableStorage = AzureTableStorage <ExternalOrderReportEntity> .Create(settings.Nested(s => s.Db.ReportsConnString), "ExternalOrderReport", log); }
protected override void Load(ContainerBuilder builder) { // NOTE: Do not register entire settings in container, pass necessary settings to services which requires them // ex: // builder.RegisterType<QuotesPublisher>() // .As<IQuotesPublisher>() // .WithParameter(TypedParameter.From(_settings.Rabbit.ConnectionString)) builder.RegisterInstance(_settings) .As <IReloadingManager <ExchangePollingJobSettings> >() .SingleInstance(); builder.RegisterInstance(_log) .As <ILog>() .SingleInstance(); builder.RegisterType <HealthService>() .As <IHealthService>() .SingleInstance(); builder.RegisterType <StartupManager>() .As <IStartupManager>(); builder.RegisterType <ShutdownManager>() .As <IShutdownManager>(); RegisterPeriodicalHandlers(builder); RegisterRabbitMqSubscribers(builder); RegisterRabbitMqPublishers(builder); builder.Register <IGenericBlobRepository>(ctx => new GenericBlobRepository(_settings.Nested(x => x.Db.BlobConnString))) .SingleInstance(); builder.RegisterType <ExchangePollingService>() .As <IExchangePollingService>() .SingleInstance(); builder.RegisterType <QuoteService>() .As <IQuoteService>() .SingleInstance(); builder.RegisterType <ExchangeCache>() .As <IExchangeCache>() .SingleInstance(); builder.RegisterType <QuoteCache>() .As <IQuoteCache>() .SingleInstance(); builder.RegisterType <ExchangeConnectorService>() .As <IExchangeConnectorService>() .WithParameter("settings", new ExchangeConnectorServiceSettings { ServiceUrl = _settings.CurrentValue.Services.ExchangeConnectorService.Url, ApiKey = _settings.CurrentValue.Services.ExchangeConnectorService.ApiKey }) .SingleInstance(); builder.Populate(_services); }
protected override void Load(ContainerBuilder builder) { builder.RegisterInstance(_log).As <ILog>().SingleInstance(); if (_settings.CurrentValue.Db.StorageMode == StorageMode.Azure) { builder.Register(ctx => _settings.CurrentValue.UseSerilog ? (IOperationsLogRepository) new SerilogOperationsLogRepository(_log) : new OperationsLogRepository(AzureTableStorage <OperationLogEntity> .Create( _settings.Nested(s => s.Db.LogsConnString), OperationsLogName, _log))) .SingleInstance(); builder.Register <IMarginTradingBlobRepository>(ctx => AzureRepoFactories.MarginTrading.CreateBlobRepository( _settings.Nested(s => s.Db.StateConnString))) .SingleInstance(); builder.Register(c => { var settings = c.Resolve <IReloadingManager <MarginTradingSettings> >(); return(settings.CurrentValue.UseDbIdentityGenerator ? (IIdentityGenerator) new AzureIdentityGenerator( AzureTableStorage <IdentityEntity> .Create(settings.Nested(s => s.Db.MarginTradingConnString), "Identity", _log)) : (IIdentityGenerator) new SimpleIdentityGenerator()); }).As <IIdentityGenerator>().SingleInstance(); builder.RegisterType <AzureRepositories.OperationExecutionInfoRepository>() .As <IOperationExecutionInfoRepository>() .WithParameter(new NamedParameter("connectionStringManager", _settings.Nested(x => x.Db.MarginTradingConnString))) .SingleInstance(); builder.RegisterDecorator <RfqExecutionInfoRepositoryDecorator, IOperationExecutionInfoRepository>(); builder.RegisterType <AzureRepositories.OpenPositionsRepository>() .As <IOpenPositionsRepository>() .WithParameter(new NamedParameter("connectionStringManager", _settings.Nested(x => x.Db.MarginTradingConnString))) .SingleInstance(); builder.RegisterType <AzureRepositories.AccountStatRepository>() .As <IAccountStatRepository>() .WithParameter(new NamedParameter("connectionStringManager", _settings.Nested(x => x.Db.MarginTradingConnString))) .SingleInstance(); builder.RegisterType <AzureRepositories.TradingEngineSnapshotsRepository>() .As <ITradingEngineSnapshotsRepository>() .SingleInstance(); } else if (_settings.CurrentValue.Db.StorageMode == StorageMode.SqlServer) { builder.Register(ctx => _settings.CurrentValue.UseSerilog ? (IOperationsLogRepository) new SerilogOperationsLogRepository(_log) : new SqlOperationsLogRepository(ctx.Resolve <IDateService>(), OperationsLogName, _settings.CurrentValue.Db.LogsConnString)) .SingleInstance(); builder.Register <IMarginTradingBlobRepository>(ctx => new SqlBlobRepository(_settings.CurrentValue.Db.StateConnString)) .SingleInstance(); builder.Register(c => c.Resolve <IReloadingManager <MarginTradingSettings> >().CurrentValue .UseDbIdentityGenerator ? (IIdentityGenerator) new SqlIdentityGenerator() : (IIdentityGenerator) new SimpleIdentityGenerator()) .As <IIdentityGenerator>() .SingleInstance(); builder.RegisterType <SqlRepositories.Repositories.OperationExecutionInfoRepository>() .As <IOperationExecutionInfoRepository>() .WithParameter(new NamedParameter("connectionString", _settings.CurrentValue.Db.SqlConnectionString)) .SingleInstance(); builder.RegisterDecorator <RfqExecutionInfoRepositoryDecorator, IOperationExecutionInfoRepository>(); builder.RegisterType <SqlRepositories.Repositories.OpenPositionsRepository>() .As <IOpenPositionsRepository>() .WithParameter(new NamedParameter("connectionString", _settings.CurrentValue.Db.SqlConnectionString)) .SingleInstance(); builder.RegisterType <SqlRepositories.Repositories.AccountStatRepository>() .As <IAccountStatRepository>() .WithParameter(new NamedParameter("connectionString", _settings.CurrentValue.Db.SqlConnectionString)) .SingleInstance(); builder.RegisterType <SqlRepositories.Repositories.OrdersHistoryRepository>() .As <IOrdersHistoryRepository>() .WithParameter(new NamedParameter("connectionString", _settings.CurrentValue.Db.OrdersHistorySqlConnectionString)) .WithParameter(new NamedParameter("tableName", _settings.CurrentValue.Db.OrdersHistoryTableName)) .WithParameter(new NamedParameter("getLastSnapshotTimeoutS", _settings.CurrentValue.Db.QueryTimeouts.GetLastSnapshotTimeoutS)) .SingleInstance(); builder.RegisterType <SqlRepositories.Repositories.PositionsHistoryRepository>() .As <IPositionsHistoryRepository>() .WithParameter(new NamedParameter("connectionString", _settings.CurrentValue.Db.PositionsHistorySqlConnectionString)) .WithParameter(new NamedParameter("tableName", _settings.CurrentValue.Db.PositionsHistoryTableName)) .WithParameter(new NamedParameter("getLastSnapshotTimeoutS", _settings.CurrentValue.Db.QueryTimeouts.GetLastSnapshotTimeoutS)) .SingleInstance(); builder.RegisterType <AccountHistoryRepository>() .As <IAccountHistoryRepository>() .WithParameter(new NamedParameter("connectionString", _settings.CurrentValue.Db.SqlConnectionString)) .SingleInstance(); builder.RegisterType <SqlRepositories.Repositories.TradingEngineSnapshotsRepository>() .As <ITradingEngineSnapshotsRepository>() .SingleInstance(); builder.RegisterType <SqlRepositories.Repositories.OperationExecutionPauseRepository>() .As <IOperationExecutionPauseRepository>() .WithParameter(new NamedParameter("connectionString", _settings.CurrentValue.Db.SqlConnectionString)) .SingleInstance(); builder.RegisterDecorator <RfqExecutionPauseRepositoryDecorator, IOperationExecutionPauseRepository>(); } builder.RegisterType <MatchingEngineInMemoryRepository>().As <IMatchingEngineRepository>().SingleInstance(); builder.Register(c => { var settings = c.Resolve <IReloadingManager <MarginTradingSettings> >(); return(settings.CurrentValue.UseDbIdentityGenerator ? (IIdentityGenerator) new AzureIdentityGenerator( AzureTableStorage <IdentityEntity> .Create(settings.Nested(s => s.Db.MarginTradingConnString), "Identity", _log)) : (IIdentityGenerator) new SimpleIdentityGenerator()); }).As <IIdentityGenerator>().SingleInstance(); //SQL PLACE builder.RegisterType <AccountMarginFreezingRepository>() .As <IAccountMarginFreezingRepository>() .SingleInstance(); builder.RegisterType <AccountMarginUnconfirmedRepository>() .As <IAccountMarginUnconfirmedRepository>() .SingleInstance(); InitializeDapper(); }
public ServicesModule( IReloadingManager <AppSettings> appSettings) { _jobSettings = appSettings.Nested(x => x.NeoGasDistributor).CurrentValue; }
private void RegisterCandles(ContainerBuilder builder) { builder.RegisterInstance(_candlesShardRemoteSettings) .AsSelf() .SingleInstance(); builder.RegisterType <HealthService>() .As <IHealthService>() .SingleInstance(); builder.RegisterType <HealthLogger>() .As <IStartable>() .SingleInstance() .AutoActivate(); if (_settings.Db.StorageMode == StorageMode.SqlServer) { builder.RegisterType <SqlCandlesHistoryRepository>() .As <ICandlesHistoryRepository>() .WithParameter(TypedParameter.From(_dbSettings.Nested(s => s.SnapshotsConnectionString))) .SingleInstance(); } else if (_settings.Db.StorageMode == StorageMode.Azure) { builder.RegisterType <CandlesHistoryRepository>() .As <ICandlesHistoryRepository>() .WithParameter(TypedParameter.From(_dbSettings.Nested(s => s.SnapshotsConnectionString))) .SingleInstance(); } if (_settings.Migration != null) { builder.RegisterType <StartupManager>() .As <IStartupManager>() .WithParameter(TypedParameter.From(_settings.Migration.MigrationEnabled)) .SingleInstance(); builder.RegisterType <ShutdownManager>() .As <IShutdownManager>() .WithParameter(TypedParameter.From(_settings.Migration.MigrationEnabled)) .SingleInstance(); } else { builder.RegisterType <StartupManager>() .As <IStartupManager>() .WithParameter(TypedParameter.From(false)) .SingleInstance(); builder.RegisterType <ShutdownManager>() .As <IShutdownManager>() .WithParameter(TypedParameter.From(false)) .SingleInstance(); } builder.RegisterType <SnapshotSerializer>() .As <ISnapshotSerializer>() .SingleInstance(); // Now creating a silent -or- logging candles checker object. // CandlesChecker -- logs notifications on candles without properly configured connection strings for asset pair using the specified timeout between similar notifications. // CandlesHistorySilent -- does not log notifications. if (_settings.ErrorManagement.NotifyOnCantStoreAssetPair) { builder.RegisterType <CandlesChecker>() .As <ICandlesChecker>() .WithParameter(TypedParameter.From(_settings.ErrorManagement.NotifyOnCantStoreAssetPairTimeout)) .SingleInstance(); } else { builder.RegisterType <CandlesCheckerSilent>() .As <ICandlesChecker>() .SingleInstance(); } builder.RegisterType <CandlesSubscriber>() .As <ICandlesSubscriber>() .WithParameter(TypedParameter.From(_settings.Rabbit.CandlesSubscription)) .WithParameter(TypedParameter.From(_settings.Rabbit.Prefetch)) .SingleInstance(); builder.RegisterType <CandlesManager>() .As <ICandlesManager>() .SingleInstance(); builder.RegisterType <CandlesAmountManager>() .WithParameter(TypedParameter.From(_settings.CleanupSettings)) .WithParameter(TypedParameter.From(_settings.HistoryTicksCacheSize)) .As <ICandlesAmountManager>() .SingleInstance(); builder.RegisterType <RedisCandlesCacheService>() .As <ICandlesCacheService>() .WithParameter(TypedParameter.From(_marketType)) .SingleInstance(); builder.RegisterType <CandlesPersistenceManager>() .As <ICandlesPersistenceManager>() .SingleInstance() .WithParameter(TypedParameter.From(_settings.Persistence)); builder.RegisterType <CandlesPersistenceQueue>() .As <ICandlesPersistenceQueue>() .SingleInstance() .WithParameter(TypedParameter.From(_settings.Persistence)) .WithParameter(TypedParameter.From(_settings.Db.StorageMode)); builder.RegisterType <QueueMonitor>() .As <IStartable>() .SingleInstance() .WithParameter(TypedParameter.From(_settings.QueueMonitor)) .AutoActivate(); builder.RegisterType <CandlesCacheInitalizationService>() .As <ICandlesCacheInitalizationService>(); if (_settings.Db.StorageMode == StorageMode.SqlServer) { builder.Register <ICandlesPersistenceQueueSnapshotRepository>(ctx => new SqlCandlesPersistenceQueueSnapshotRepository(_dbSettings.CurrentValue.SnapshotsConnectionString)) .SingleInstance(); builder.RegisterType <SqlCandlesCleanup>() .WithParameter(TypedParameter.From(_settings.CleanupSettings)) .WithParameter(TypedParameter.From(_settings.Db.SnapshotsConnectionString)) .As <ICandlesCleanup>(); } else if (_settings.Db.StorageMode == StorageMode.Azure) { builder.RegisterType <CandlesPersistenceQueueSnapshotRepository>() .As <ICandlesPersistenceQueueSnapshotRepository>() .WithParameter(TypedParameter.From(AzureBlobStorage.Create(_dbSettings.ConnectionString(x => x.SnapshotsConnectionString), TimeSpan.FromMinutes(10)))); builder.Register(ctx => Mock.Of <SqlCandlesCleanup>()).As <ICandlesCleanup>(); } builder.RegisterType <RedisCacheTruncator>() .As <IStartable>() .SingleInstance() .WithParameter(TypedParameter.From(_marketType)) .WithParameter(TypedParameter.From(_settings.CacheCleanupPeriod)) .AutoActivate(); builder.RegisterType <CandlesShardValidator>() .As <ICandlesShardValidator>() .SingleInstance(); RegisterCandlesMigration(builder); RegisterCandlesFiltration(builder); }
private static void SetupLoggers(IConfiguration configuration, IServiceCollection services, IReloadingManager <MtBackendSettings> mtSettings, CorrelationContextAccessor correlationContextAccessor) { var settings = mtSettings.Nested(x => x.MtBackend); const string requestsLogName = "MarginTradingBackendRequestsLog"; const string logName = "MarginTradingBackendLog"; var consoleLogger = new LogToConsole(); #region Logs settings validation if (!settings.CurrentValue.UseSerilog && string.IsNullOrWhiteSpace(settings.CurrentValue.Db.LogsConnString)) { throw new Exception("Either UseSerilog must be true or LogsConnString must be set"); } #endregion Logs settings validation #region Slack registration IMtSlackNotificationsSender slackService = null; if (mtSettings.CurrentValue.SlackNotifications != null) { var azureQueue = new AzureQueueSettings { ConnectionString = mtSettings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = mtSettings.CurrentValue.SlackNotifications.AzureQueue.QueueName }; var commonSlackService = services.UseSlackNotificationsSenderViaAzureQueue(azureQueue, consoleLogger); slackService = new MtSlackNotificationsSender(commonSlackService, "MT Backend", settings.CurrentValue.Env); } #endregion Slack registration if (settings.CurrentValue.UseSerilog) { LogLocator.RequestsLog = LogLocator.CommonLog = new SerilogLogger(typeof(Startup).Assembly, configuration, new List <Func <(string Name, object Value)> > { () => ("BrokerId", settings.CurrentValue.BrokerId) }, new List <ILogEventEnricher> { new CorrelationLogEventEnricher("CorrelationId", correlationContextAccessor) }); } else if (settings.CurrentValue.Db.StorageMode == StorageMode.SqlServer) { LogLocator.RequestsLog = new AggregateLogger( new LogToSql(new SqlLogRepository(requestsLogName, settings.CurrentValue.Db.LogsConnString)), new LogToConsole()); LogLocator.CommonLog = new AggregateLogger( new LogToSql(new SqlLogRepository(logName, settings.CurrentValue.Db.LogsConnString)), new LogToConsole()); } else if (settings.CurrentValue.Db.StorageMode == StorageMode.Azure) { if (slackService == null) { slackService = new MtSlackNotificationsSenderLogStub("MT Backend", settings.CurrentValue.Env, consoleLogger); } LogLocator.RequestsLog = services.UseLogToAzureStorage(settings.Nested(s => s.Db.LogsConnString), slackService, requestsLogName, consoleLogger); LogLocator.CommonLog = services.UseLogToAzureStorage(settings.Nested(s => s.Db.LogsConnString), slackService, logName, consoleLogger); } if (slackService == null) { slackService = new MtSlackNotificationsSenderLogStub("MT Backend", settings.CurrentValue.Env, LogLocator.CommonLog); } services.AddSingleton <ISlackNotificationsSender>(slackService); services.AddSingleton <IMtSlackNotificationsSender>(slackService); services.AddSingleton <ILoggerFactory>(x => new WebHostLoggerFactory(LogLocator.CommonLog)); }
public JobModule(IReloadingManager <AppSettings> appSettings) { _publisherSettings = appSettings.CurrentValue.QuorumTransactionWatcherJob.Publisher; _blockchainSettings = appSettings.Nested(s => s.QuorumTransactionWatcherJob.Blockchain); }
public OrderbookBestPricesRepository(IReloadingManager <Settings> settings, ILog log) { _tableStorage = AzureTableStorage <OrderbookBestPricesHistoryEntity> .Create(settings.Nested(s => s.Db.HistoryConnString), "OrderbookBestPrices", log); }
private static IMessageProducer <ExternalExchangeOrderbookMessage> CreateRabbitMqMessageProducer( IReloadingManager <MarginTradingOrderbookAggregatorSettings> settings, IRabbitMqService rabbitMqService) { return(rabbitMqService.GetProducer(settings.Nested(s => s.RabbitMq.Publishers.Orderbooks), true, rabbitMqService.GetMsgPackSerializer <ExternalExchangeOrderbookMessage>())); }
public ServiceModule(IReloadingManager <AppSettings> settings) { _settings = settings.Nested(x => x.CustomerApiService).CurrentValue; _mobileSettings = settings.Nested(x => x.MobileAppSettings).CurrentValue; }
public DbModule(IReloadingManager <AppSettings> appSettings) { _connectionString = appSettings.CurrentValue.SmartVouchersService.Db.SqlDbConnString; _rulesImageConnString = appSettings.Nested(s => s.SmartVouchersService.Db.CampaignsImageConnString); }
private static ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <AppSettings> settings) { var consoleLogger = new LogToConsole(); var aggregateLogger = new AggregateLogger(); aggregateLogger.AddLog(consoleLogger); var dbLogConnectionStringManager = settings.Nested(x => x.BitcoinGoldApi.Db.LogsConnString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; if (string.IsNullOrEmpty(dbLogConnectionString)) { consoleLogger.WriteWarningAsync(nameof(Startup), nameof(CreateLogWithSlack), "Table loggger is not inited").Wait(); return(aggregateLogger); } if (dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}")) { throw new InvalidOperationException($"LogsConnString {dbLogConnectionString} is not filled in settings"); } var persistenceManager = new LykkeLogToAzureStoragePersistenceManager( AzureTableStorage <LogEntity> .Create(dbLogConnectionStringManager, "BitcoinGoldApiLog", consoleLogger), consoleLogger); // Creating slack notification service, which logs own azure queue processing messages to aggregate log var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueIntegration.AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }, aggregateLogger); var slackNotificationsManager = new LykkeLogToAzureSlackNotificationsManager(slackService, consoleLogger); // Creating azure storage logger, which logs own messages to concole log var azureStorageLogger = new LykkeLogToAzureStorage( persistenceManager, slackNotificationsManager, consoleLogger); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); var allMessagesSlackLogger = LykkeLogToSlack.Create ( slackService, "BlockChainIntegration", // ReSharper disable once RedundantArgumentDefaultValue LogLevel.All ); aggregateLogger.AddLog(allMessagesSlackLogger); var importantMessagesSlackLogger = LykkeLogToSlack.Create ( slackService, "BlockChainIntegrationImportantMessages", LogLevel.All ^ LogLevel.Info ); aggregateLogger.AddLog(importantMessagesSlackLogger); return(aggregateLogger); }
public RepositoriesModule( IReloadingManager <AppSettings> appSettings) { _connectionString = appSettings.Nested(x => x.NeoGasDistributor.Db.DataConnString); }
public BlockchainModule(IReloadingManager <AppSettings> appSettings) { _blockchainSettings = appSettings.Nested(e => e.QuorumOperationExecutorService.Blockchain); }
protected override void Load(ContainerBuilder builder) { // TODO: Do not register entire settings in container, pass necessary settings to services which requires them // ex: // builder.RegisterType<QuotesPublisher>() // .As<IQuotesPublisher>() // .WithParameter(TypedParameter.From(_settings.CurrentValue.QuotesPublication)) builder.RegisterInstance(_log) .As <ILog>() .SingleInstance(); builder.RegisterType <HealthService>() .As <IHealthService>() .SingleInstance(); builder.RegisterType <StartupManager>() .As <IStartupManager>(); builder.RegisterType <ShutdownManager>() .As <IShutdownManager>(); builder.RegisterType <AddressRepository>() .As <IAddressRepository>() .WithParameter(TypedParameter.From(_settings.Nested(s => s.Db.DataConnString))) .SingleInstance(); builder.RegisterType <HistoryRepository>() .As <IHistoryRepository>() .WithParameter(TypedParameter.From(_settings.Nested(s => s.Db.DataConnString))) .SingleInstance(); builder.RegisterType <OperationRepository>() .As <IOperationRepository>() .WithParameter(TypedParameter.From(_settings.Nested(s => s.Db.DataConnString))) .SingleInstance(); builder.RegisterType <SettingsRepository>() .As <ISettingsRepository>() .WithParameter(TypedParameter.From(_settings.Nested(s => s.Db.DataConnString))) .SingleInstance(); ZcashNetworks.Instance.EnsureRegistered(); builder.RegisterInstance(Network.GetNetwork(_settings.CurrentValue.NetworkType)) .As <Network>(); builder.RegisterType <RPCClient>() .AsSelf() .WithParameter("authenticationString", _settings.CurrentValue.RpcAuthenticationString) .WithParameter("hostOrUri", _settings.CurrentValue.RpcUrl); builder.RegisterType <BlockchainReader>() .As <IBlockchainReader>(); builder.RegisterType <BlockchainService>() .As <IBlockchainService>() .WithParameter(TypedParameter.From(_settings.CurrentValue)); RegisterPeriodicalHandlers(builder); builder.Populate(_services); }
public ServiceModule(IReloadingManager <AppSettings> settings, ILog log) { _allSettings = settings; _settings = settings.Nested(x => x.GoogleAnalyticsWrapperService); _log = log; }
protected override void Load(ContainerBuilder builder) { builder.RegisterInstance(_console) .As <IConsole>() .SingleInstance(); builder.RegisterInstance(_log) .As <ILog>() .SingleInstance(); builder.RegisterType <HealthService>() .As <IHealthService>() .SingleInstance(); builder.RegisterType <StartupManager>() .As <IStartupManager>(); builder.RegisterType <ShutdownManager>() .As <IShutdownManager>(); builder.RegisterResourcesMonitoring(_log); builder.RegisterType <AssetsService>() .WithParameter(TypedParameter.From(new Uri(_settings.AssetsServiceClient.ServiceUrl))) .As <IAssetsService>() .SingleInstance(); builder.RegisterType <CachesManager>() .As <ICachesManager>() .As <IStartable>() .As <IStopable>() .SingleInstance(); builder.RegisterType <AssetsDictionary>() .As <IAssetsDictionary>() .SingleInstance(); builder.RegisterType <TradeVolumesRepository>() .WithParameter(TypedParameter.From(_settingsManager.Nested(x => x.TradeVolumesService.TradeVolumesConnString))) .As <ITradeVolumesRepository>() .SingleInstance(); int warningHoursDelay = 1; if (_settings.TradeVolumesService.WarningDelayInHours > 0) { warningHoursDelay = _settings.TradeVolumesService.WarningDelayInHours; } int tradesCacheHoursTimeout = 6; if (_settings.TradeVolumesService.TradesCacheTimeoutInHours > 0) { tradesCacheHoursTimeout = _settings.TradeVolumesService.TradesCacheTimeoutInHours; } int tradesCacheWarningCount = 1000; if (_settings.TradeVolumesService.TradesCacheWarningCount > 0) { tradesCacheWarningCount = _settings.TradeVolumesService.TradesCacheWarningCount; } builder.RegisterType <TradeVolumesCalculator>() .As <ITradeVolumesCalculator>() .As <IStartable>() .As <IStopable>() .SingleInstance() .WithParameter("warningDelay", TimeSpan.FromHours(warningHoursDelay)) .WithParameter("cacheWarningCount", tradesCacheWarningCount) .WithParameter("cacheTimeout", TimeSpan.FromHours(tradesCacheHoursTimeout)); if (!_settings.TradeVolumesService.DisableRabbitMqConnection.HasValue || !_settings.TradeVolumesService.DisableRabbitMqConnection.Value) { builder.RegisterType <TradelogSubscriber>() .As <IStartable>() .As <IStopable>() .SingleInstance() .WithParameter("connectionString", _settings.TradeVolumesService.RabbitMqConnString) .WithParameter("exchangeName", _settings.TradeVolumesService.TradelogExchangeName); } }
protected override void Load( ContainerBuilder builder) { var connectionString = _appSettings.ConnectionString(x => x.Job.Db.DataConnString); var jobSettings = _appSettings.Nested(x => x.Job); var rpcNodeSettings = jobSettings.CurrentValue.RpcNode; BigInteger?maximalBalanceCheckPeriod = null; if (!string.IsNullOrEmpty(jobSettings.CurrentValue.MaximalBalanceCheckPeriod)) { maximalBalanceCheckPeriod = BigInteger.Parse(jobSettings.CurrentValue.MaximalBalanceCheckPeriod); } builder .RegisterChaosKitty(_appSettings.CurrentValue.Chaos); builder .UseRpcClient ( rpcNodeSettings.ApiUrl, rpcNodeSettings.ConnectionTimeout, rpcNodeSettings.EnableTelemetry ) .AddDefaultEthApi() .AddDefaultParityApi(); builder .UseAzureRepositories(connectionString) .AddDefaultBalanceCheckSchedulerLockRepository() .AddDefaultBalanceRepository() .AddDefaultBalanceMonitoringTaskRepository() .AddDefaultBlacklistedAddressRepository() .AddDefaultBlockchainIndexationStateRepository() .AddDefaultBlockIndexationLockRepository() .AddDefaultTransactionReceiptRepository() .AddDefaultTransactionRepository() .AddDefaultTransactionMonitoringTaskRepository() .AddDefaultWhitelistedAddressRepository(); builder .RegisterServices ( jobSettings.CurrentValue.BlockLockDuration, jobSettings.Nested(x => x.ConfirmationLevel), jobSettings.Nested(x => x.GasPriceRange), jobSettings.CurrentValue.IndexOnlyOwnTransactions, maximalBalanceCheckPeriod, BigInteger.Parse(jobSettings.CurrentValue.MinBlockNumberToIndex) ) .AddDefaultBalanceCheckSchedulingService() .AddDefaultBalanceMonitoringService() .AddDefaultBlockchainIndexingService() .AddDefaultTransactionMonitoringService(); builder .UseQueueConsumers ( jobSettings.CurrentValue.BalanceMonitoringMaxDegreeOfParallelism, jobSettings.CurrentValue.BlockchainIndexationMaxDegreeOfParallelism, jobSettings.CurrentValue.TransactionMonitoringMaxDegreeOfParallelism ) .AddBalanceMonitoringQueueConsumer() .AddBlockchainIndexationQueueConsumer() .AddTransactionMonitoringQueueConsumer(); if (maximalBalanceCheckPeriod.HasValue) { builder.RegisterType <DefaultBalanceCheckScheduler>() .IfNotRegistered(typeof(IBalanceCheckScheduler)) .As <IStartable>() .As <IStopable>() .SingleInstance(); } }
private static ILog CreateLogWithSlack(IConfiguration configuration, IServiceCollection services, IReloadingManager <AppSettings> settings) { const string requestsLogName = "SettingsServiceRequestsLog"; const string logName = "SettingsServiceLog"; var consoleLogger = new LogToConsole(); #region Logs settings validation if (!settings.CurrentValue.MarginTradingAssetService.UseSerilog && string.IsNullOrWhiteSpace(settings.CurrentValue.MarginTradingAssetService.Db.LogsConnString)) { throw new Exception("Either UseSerilog must be true or LogsConnString must be set"); } #endregion Logs settings validation #region Slack registration ISlackNotificationsSender slackService = null; if (settings.CurrentValue.SlackNotifications != null) { var azureQueue = new AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }; slackService = services.UseSlackNotificationsSenderViaAzureQueue(azureQueue, consoleLogger); } #endregion Slack registration if (settings.CurrentValue.MarginTradingAssetService.UseSerilog) { var serilogLogger = new SerilogLogger(typeof(Startup).Assembly, configuration, new List <Func <(string Name, object Value)> >() { () => ("BrokerId", settings.CurrentValue.MarginTradingAssetService.BrokerId), }); LogLocator.RequestsLog = LogLocator.CommonLog = serilogLogger; return(serilogLogger); } if (settings.CurrentValue.MarginTradingAssetService.Db.StorageMode == StorageMode.SqlServer) { LogLocator.CommonLog = new AggregateLogger( new LogToSql(new SqlLogRepository(logName, settings.CurrentValue.MarginTradingAssetService.Db.LogsConnString)), new LogToConsole()); LogLocator.RequestsLog = new AggregateLogger( new LogToSql(new SqlLogRepository(requestsLogName, settings.CurrentValue.MarginTradingAssetService.Db.LogsConnString)), new LogToConsole()); return(LogLocator.CommonLog); } if (settings.CurrentValue.MarginTradingAssetService.Db.StorageMode != StorageMode.Azure) { throw new Exception("Wrong config! Logging must be set either to Serilog, SqlServer or Azure."); } #region Azure logging LogLocator.RequestsLog = services.UseLogToAzureStorage(settings.Nested(s => s.MarginTradingAssetService.Db.LogsConnString), slackService, requestsLogName, consoleLogger); LogLocator.CommonLog = services.UseLogToAzureStorage(settings.Nested(s => s.MarginTradingAssetService.Db.LogsConnString), slackService, logName, consoleLogger); return(LogLocator.CommonLog); #endregion Azure logging }
public SettingsStorageService(IReloadingManager <MarginTradingOrderbookAggregatorSettings> settings, IConvertService convertService, IAzureBlobStorageFactoryService azureBlobStorageFactoryService) { _convertService = convertService; _blobStorage = azureBlobStorageFactoryService.Create(settings.Nested(s => s.Db.ConnectionString)); }
protected override void Load(ContainerBuilder builder) { // TODO: Do not register entire settings in container, pass necessary settings to services which requires them // ex: // builder.RegisterType<QuotesPublisher>() // .As<IQuotesPublisher>() // .WithParameter(TypedParameter.From(_settings.CurrentValue.QuotesPublication)) builder.RegisterInstance(_log) .As <ILog>() .SingleInstance(); builder.RegisterType <HealthService>() .As <IHealthService>() .SingleInstance(); builder.RegisterType <StartupManager>() .As <IStartupManager>(); builder.RegisterType <ShutdownManager>() .As <IShutdownManager>(); builder.RegisterType <PayInAddressRepository>() .As <IPayInAddressRepository>() .WithParameter(TypedParameter.From(_settings.Nested(x => x.Db.DataConnString))) .SingleInstance(); builder.RegisterType <EmailRepository>() .As <IEmailRepository>() .WithParameter(TypedParameter.From(_settings.Nested(x => x.Db.DataConnString))) .SingleInstance(); builder.RegisterType <EmailTemplateRepository>() .As <IEmailTemplateRepository>() .WithParameter(TypedParameter.From(_settings.Nested(x => x.Db.DataConnString))) .SingleInstance(); builder.RegisterType <TransactionRepository>() .As <ITransactionRepository>() .WithParameter(TypedParameter.From(_settings.Nested(x => x.Db.DataConnString))) .SingleInstance(); builder.RegisterType <CampaignSettingsRepository>() .As <ICampaignSettingsRepository>() .WithParameter(TypedParameter.From(_settings.Nested(x => x.Db.DataConnString))) .SingleInstance(); builder.RegisterType <SmtpService>() .As <ISmtpService>(); builder.RegisterType <EmailTemplateService>() .As <IEmailTemplateService>() .SingleInstance(); builder.RegisterType <EmailService>() .As <IEmailService>(); builder.RegisterType <TransactionService>() .As <ITransactionService>(); RegisterAzureQueueHandlers(builder); builder.Populate(_services); }
protected override void Load(ContainerBuilder builder) { builder.RegisterModule(new DomainServices.AutofacModule()); builder.RegisterModule(new AzureRepositories.AutofacModule(_settings.Nested(o => o.MarketInstrumentsService.Db.DataConnectionString))); }
protected override void Load(ContainerBuilder builder) { builder.RegisterInstance(_log) .As <ILog>() .SingleInstance(); builder.Register <IMarginTradingOperationsLogRepository>(ctx => new MarginTradingOperationsLogRepository( AzureTableStorage <OperationLogEntity> .Create(_settings.Nested(s => s.Db.LogsConnString), "MarginTradingBackendOperationsLog", _log)) ).SingleInstance(); builder.Register <IMarginTradingAccountsRepository>(ctx => AzureRepoFactories.MarginTrading.CreateAccountsRepository(_settings.Nested(s => s.Db.MarginTradingConnString), _log) ).SingleInstance(); builder.Register <IMarginTradingOrdersHistoryRepository>(ctx => AzureRepoFactories.MarginTrading.CreateOrdersHistoryRepository(_settings.Nested(s => s.Db.HistoryConnString), _log) ).SingleInstance(); builder.Register <IMarginTradingAccountHistoryRepository>(ctx => AzureRepoFactories.MarginTrading.CreateAccountHistoryRepository(_settings.Nested(s => s.Db.HistoryConnString), _log) ).SingleInstance(); builder.Register <IMatchingEngineRoutesRepository>(ctx => AzureRepoFactories.MarginTrading.CreateMatchingEngineRoutesRepository(_settings.Nested(s => s.Db.MarginTradingConnString), _log) ).SingleInstance(); builder.Register <ITradingConditionRepository>(ctx => AzureRepoFactories.MarginTrading.CreateTradingConditionsRepository(_settings.Nested(s => s.Db.MarginTradingConnString), _log) ).SingleInstance(); builder.Register <IAccountGroupRepository>(ctx => AzureRepoFactories.MarginTrading.CreateAccountGroupRepository(_settings.Nested(s => s.Db.MarginTradingConnString), _log) ).SingleInstance(); builder.Register <IAccountAssetPairsRepository>(ctx => AzureRepoFactories.MarginTrading.CreateAccountAssetsRepository(_settings.Nested(s => s.Db.MarginTradingConnString), _log) ).SingleInstance(); builder.Register <IMarginTradingBlobRepository>(ctx => AzureRepoFactories.MarginTrading.CreateBlobRepository(_settings.Nested(s => s.Db.StateConnString)) ).SingleInstance(); builder.Register <IRiskSystemCommandsLogRepository>(ctx => AzureRepoFactories.MarginTrading.CreateRiskSystemCommandsLogRepository(_settings.Nested(s => s.Db.LogsConnString), _log) ).SingleInstance(); builder.Register <IOvernightSwapStateRepository>(ctx => AzureRepoFactories.MarginTrading.CreateOvernightSwapStateRepository(_settings.Nested(s => s.Db.StateConnString), _log) ).SingleInstance(); builder.Register <IOvernightSwapHistoryRepository>(ctx => AzureRepoFactories.MarginTrading.CreateOvernightSwapHistoryRepository(_settings.Nested(s => s.Db.HistoryConnString), _log) ).SingleInstance(); builder.Register(ctx => AzureRepoFactories.MarginTrading.CreateDayOffSettingsRepository(_settings.Nested(s => s.Db.MarginTradingConnString)) ).SingleInstance(); builder.Register(ctx => AzureRepoFactories.MarginTrading.CreateAssetPairSettingsRepository( _settings.Nested(s => s.Db.MarginTradingConnString), _log, ctx.Resolve <IConvertService>()) ).SingleInstance(); builder.RegisterType <MatchingEngineInMemoryRepository>() .As <IMatchingEngineRepository>() .SingleInstance(); builder.Register(c => { var settings = c.Resolve <IReloadingManager <MarginSettings> >(); return(settings.CurrentValue.UseAzureIdentityGenerator ? (IIdentityGenerator) new AzureIdentityGenerator( AzureTableStorage <IdentityEntity> .Create(settings.Nested(s => s.Db.MarginTradingConnString), "Identity", _log)) : (IIdentityGenerator) new FakeIdentityGenerator()); }) .As <IIdentityGenerator>() .SingleInstance(); }
protected override void Load(ContainerBuilder builder) { builder.RegisterInstance(_log) .As <ILog>() .SingleInstance(); builder.RegisterType <HealthService>() .As <IHealthService>() .SingleInstance(); builder.RegisterType <StartupManager>() .As <IStartupManager>(); builder.RegisterType <ShutdownManager>() .As <IShutdownManager>(); builder.RegisterIcoExRateClient(_settings.IcoExRateServiceUrl, _log); builder.RegisterType <InvestorRepository>() .As <IInvestorRepository>() .WithParameter(TypedParameter.From(_dbSettingsManager.Nested(x => x.DataConnString))); builder.RegisterType <InvestorAttributeRepository>() .As <IInvestorAttributeRepository>() .WithParameter(TypedParameter.From(_dbSettingsManager.Nested(x => x.DataConnString))); builder.RegisterType <PrivateInvestorAttributeRepository>() .As <IPrivateInvestorAttributeRepository>() .WithParameter(TypedParameter.From(_dbSettingsManager.Nested(x => x.DataConnString))); builder.RegisterType <CampaignInfoRepository>() .As <ICampaignInfoRepository>() .WithParameter(TypedParameter.From(_dbSettingsManager.Nested(x => x.DataConnString))); builder.RegisterType <CampaignSettingsRepository>() .As <ICampaignSettingsRepository>() .WithParameter(TypedParameter.From(_dbSettingsManager.Nested(x => x.DataConnString))); builder.RegisterType <InvestorTransactionRepository>() .As <IInvestorTransactionRepository>() .WithParameter(TypedParameter.From(_dbSettingsManager.Nested(x => x.DataConnString))); builder.RegisterType <InvestorRefundRepository>() .As <IInvestorRefundRepository>() .WithParameter(TypedParameter.From(_dbSettingsManager.Nested(x => x.DataConnString))); builder.RegisterType <QueuePublisher <InvestorNewTransactionMessage> >() .As <IQueuePublisher <InvestorNewTransactionMessage> >() .WithParameter(TypedParameter.From(_azureQueueSettingsManager.Nested(x => x.ConnectionString))); builder.RegisterType <TransactionService>() .As <ITransactionService>() .WithParameter("siteSummaryPageUrl", _settings.SiteSummaryPageUrl) .SingleInstance(); builder.RegisterType <UrlEncryptionService>() .As <IUrlEncryptionService>() .WithParameter("key", _settings.KycServiceEncriptionKey) .WithParameter("iv", _settings.KycServiceEncriptionIv) .SingleInstance(); builder.RegisterType <KycService>() .As <IKycService>() .SingleInstance(); builder.RegisterType <ReferralCodeService>() .As <IReferralCodeService>() .SingleInstance(); builder.AddTriggers( pool => { pool.AddDefaultConnection(_azureQueueSettingsManager.ConnectionString(x => x.ConnectionString)); }); }
public AccountMarginEventsRepository(IReloadingManager <Settings> settings, ILog log) { _tableStorage = AzureTableStorage <AccountMarginEventEntity> .Create(settings.Nested(s => s.Db.ConnString), "AccountMarginEvents", log); }
protected override void Load(ContainerBuilder builder) { builder.RegisterClientAccountClient(_settings.ClientAccountServiceUrl); builder.RegisterHftInternalClient(_settings.HftInternalServiceUrl); builder.Register((x) => { var marketProfile = new MarketProfileServiceClient( _settings.MyNoSqlServer.ReaderServiceUrl, _settings.MarketProfileUrl); marketProfile.Start(); return(marketProfile); }) .As <IMarketProfileServiceClient>() .SingleInstance() .AutoActivate(); builder.RegisterOperationsClient(_settings.OperationsUrl); builder.RegisterType <LykkeRegistrationClient>() .As <ILykkeRegistrationClient>() .WithParameter("serviceUrl", _settings.RegistrationUrl); builder.RegisterClientSessionClient(new SessionServiceClientSettings { ServiceUrl = _apiSettings.CurrentValue.WalletApiv2.Services.SessionUrl }); builder.RegisterType <PersonalDataService>().As <IPersonalDataService>() .WithParameter(TypedParameter.From(_apiSettings.CurrentValue.PersonalDataServiceSettings)); builder.RegisterInstance( new KycStatusServiceClient(_apiSettings.CurrentValue.KycServiceClient, _log)) .As <IKycStatusService>() .SingleInstance(); builder.RegisterInstance( new KycProfileServiceClient(_apiSettings.CurrentValue.KycServiceClient, _log)) .As <IKycProfileService>() .SingleInstance(); builder.RegisterInstance <IAssetDisclaimersClient>( new AssetDisclaimersClient(_apiSettings.CurrentValue.AssetDisclaimersServiceClient)); _services.RegisterAssetsClient(AssetServiceSettings.Create( new Uri(_settings.AssetsServiceUrl), TimeSpan.FromMinutes(60)), _log); builder.RegisterClientDictionariesClient(_apiSettings.CurrentValue.ClientDictionariesServiceClient, _log); var socketLog = new SocketLogDynamic( i => { }, s => _log.WriteInfo("MeClient", null, s)); builder.BindMeClient(_apiSettings.CurrentValue.MatchingEngineClient.IpEndpoint.GetClientIpEndPoint(), socketLog, ignoreErrors: true); builder.RegisterFeeCalculatorClient(_apiSettings.CurrentValue.FeeCalculatorServiceClient.ServiceUrl, _log); builder.RegisterAffiliateClient(_settings.AffiliateServiceClient.ServiceUrl, _log); builder.RegisterIndicesFacadeClient(new IndicesFacadeServiceClientSettings { ServiceUrl = _settings.IndicesFacadeServiceUrl }, null); builder.RegisterInstance <IAssetDisclaimersClient>(new AssetDisclaimersClient(_apiSettings.CurrentValue.AssetDisclaimersServiceClient)); builder.RegisterPaymentSystemClient(_apiSettings.CurrentValue.PaymentSystemServiceClient.ServiceUrl, _log); builder.RegisterLimitationsServiceClient(_apiSettings.CurrentValue.LimitationServiceClient.ServiceUrl); builder.RegisterClientDialogsClient(_apiSettings.CurrentValue.ClientDialogsServiceClient); builder.Register(ctx => new BlockchainWalletsClient(_apiSettings.CurrentValue.BlockchainWalletsServiceClient.ServiceUrl, _log, new BlockchainWalletsApiFactory())) .As <IBlockchainWalletsClient>() .SingleInstance(); builder.RegisterSwiftCredentialsClient(_apiSettings.CurrentValue.SwiftCredentialsServiceClient); builder.RegisterHistoryClient(new HistoryServiceClientSettings { ServiceUrl = _settings.HistoryServiceUrl }); builder.RegisterConfirmationCodesClient(_apiSettings.Nested(r => r.ConfirmationCodesClient).CurrentValue); builder.RegisterBlockchainCashoutPreconditionsCheckClient(_apiSettings.CurrentValue.BlockchainCashoutPreconditionsCheckServiceClient.ServiceUrl); #region BlockchainSettings var settings = _blockchainSettingsServiceClient; var cacheManager = new ClientCacheManager(); var factory = new Lykke.Service.BlockchainSettings.Client.HttpClientGenerator.BlockchainSettingsClientFactory(); var client = factory.CreateNew(settings.ServiceUrl, settings.ApiKey, true, cacheManager); builder.RegisterInstance(client) .As <IBlockchainSettingsClient>(); builder.RegisterInstance(client) .As <IBlockchainSettingsClient>() .SingleInstance(); builder.RegisterInstance(cacheManager) .As <IClientCacheManager>() .SingleInstance(); builder.RegisterType <BlockchainExplorersProvider>() .As <IBlockchainExplorersProvider>() .SingleInstance(); #endregion builder.RegisterPushNotificationsClient(_apiSettings.CurrentValue.PushNotificationsServiceClient.ServiceUrl); builder.RegisterTierClient(_apiSettings.CurrentValue.TierServiceClient); builder.RegisterMarketDataClient(_apiSettings.CurrentValue.MarketDataServiceClient); builder.RegisterLink4PayClient(_apiSettings.CurrentValue.Link4PayServiceClient); _services.AddSiriusApiClient(new SiriusApiOptions { ApiKey = _apiSettings.CurrentValue.SiriusApiServiceClient.ApiKey, ServerGrpcUrl = new Uri(_apiSettings.CurrentValue.SiriusApiServiceClient.GrpcServiceUrl) }); builder.RegisterEmailSenderViaAzureQueueMessageProducer(_apiSettings.ConnectionString(x => x.WalletApiv2.Db.ClientPersonalInfoConnString)); builder.RegisterTemplateFormatter(_apiSettings.CurrentValue.TemplateFormatterServiceClient.ServiceUrl, _log); builder.Populate(_services); }
public ServiceModule(IReloadingManager <AppSettings> appSettings) { _appSettings = appSettings; _dbSettings = _appSettings.Nested(x => x.BalancesService.Db); }
protected override void Load(ContainerBuilder builder) { //Services builder.RegisterType <EncryptedFileService>() .As <IEncryptedFileService>() .SingleInstance(); builder .Register(ctx => { var authTokenProvider = new AzureServiceTokenProvider(_appSettings.CurrentValue .EncryptedFileStorageService.KeyVault.KeyVaultConnectionString); var authCallback = new KeyVaultClient.AuthenticationCallback(authTokenProvider.KeyVaultTokenCallback); return(new KeyVaultClient(authCallback)); }) .As <IKeyVaultClient>() .SingleInstance(); builder .Register(ctx => { var account = CloudStorageAccount.Parse(_appSettings.CurrentValue.EncryptedFileStorageService.Db.FilesContentConnString); return(account.CreateCloudBlobClient()); }) .As <CloudBlobClient>() .SingleInstance(); builder .Register(ctx => { return(AzureBlobStorage.Create( _appSettings.Nested(x => x.EncryptedFileStorageService.Db.FilesContentConnString), TimeSpan.FromMinutes(15))); }) .As <IBlobStorage>() .SingleInstance(); var apiKeysPairs = Environment.GetEnvironmentVariable("EfsApiKeysPairs"); builder.RegisterInstance(new ApiKeyService(apiKeysPairs)) .As <IApiKeyService>() .SingleInstance(); //Repositories builder.RegisterMsSql( _appSettings.CurrentValue.EncryptedFileStorageService.Db.DataConnString, connString => new DatabaseContext(connString, false), dbConn => new DatabaseContext(dbConn)); builder.RegisterType <EncryptedFileInfoRepository>() .As <IEncryptedFileInfoRepository>() .SingleInstance(); builder.RegisterType <EncryptedFileContentRepository>() .As <IEncryptedFileContentRepository>() .SingleInstance() .WithParameter("fileStorageKey", _appSettings.CurrentValue.EncryptedFileStorageService.KeyVault.FileStorageKey); }
private static IMessageProducer <OrderCommandsBatchMessage> CreateRabbitMqMessageProducer( IReloadingManager <MarginTradingMarketMakerSettings> settings, IRabbitMqService rabbitMqService) { return(rabbitMqService.GetProducer <OrderCommandsBatchMessage>( settings.Nested(s => s.RabbitMq.Publishers.OrderCommands), false, false)); }