Exemplo n.º 1
0
        private void RegisterAssets(ContainerBuilder builder)
        {
            if (_marketType == MarketType.Spot)
            {
                _services.RegisterAssetsClient(AssetServiceSettings.Create(
                                                   new Uri(_assetSettings.ServiceUrl),
                                                   _settings.AssetsCache.ExpirationPeriod),
                                               _log);

                builder.RegisterType <AssetPairsManager>()
                .As <IAssetPairsManager>()
                .SingleInstance();
            }
            else
            {
                builder.RegisterClient <IAssetPairsApi>(_assetSettings.ServiceUrl, builderConfigure =>
                {
                    if (!string.IsNullOrWhiteSpace(_assetSettings.ApiKey))
                    {
                        builderConfigure = builderConfigure.WithApiKey(_assetSettings.ApiKey);
                    }

                    return(builderConfigure);
                });

                builder.RegisterType <MtAssetPairsManager>()
                .As <IAssetPairsManager>()
                .SingleInstance();
            }
        }
Exemplo n.º 2
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterInstance(_settings.TxDetectorJob)
            .SingleInstance();

            builder.RegisterInstance(_settings.TxDetectorJob.Ninja)
            .SingleInstance();

            builder.RegisterInstance(_log)
            .As <ILog>()
            .SingleInstance();

            builder.RegisterType <HealthService>()
            .As <IHealthService>()
            .SingleInstance()
            .WithParameter(TypedParameter.From(TimeSpan.FromSeconds(30)));

            builder.RegisterOperationsRepositoryClients(_settings.OperationsRepositoryServiceClient, _log);

            // NOTE: You can implement your own poison queue notifier. See https://github.com/LykkeCity/JobTriggers/blob/master/readme.md
            // builder.Register<PoisionQueueNotifierImplementation>().As<IPoisionQueueNotifier>();

            _services.RegisterAssetsClient(AssetServiceSettings.Create(
                                               new Uri(_settings.Assets.ServiceUrl),
                                               _settings.TxDetectorJob.AssetsCache.ExpirationPeriod), _log);

            BindMatchingEngineChannel(builder);
            BindRepositories(builder);
            BindServices(builder);
            BindNinja(builder);
            BindClients(builder);

            builder.Populate(_services);
        }
Exemplo n.º 3
0
        private void RegisterAssetsServices(ContainerBuilder builder)
        {
            if (_quotesSourceType == QuotesSourceType.Spot)
            {
                _services.UseAssetsClient(AssetServiceSettings.Create(
                                              new Uri(_assetsSettings.ServiceUrl),
                                              _settings.AssetsCache.ExpirationPeriod));

                builder.RegisterType <AssetPairsManager>()
                .As <IAssetPairsManager>()
                .SingleInstance();
            }
            else
            {
                builder.RegisterClient <IAssetPairsApi>(_assetsSettings.ServiceUrl, builderConfigure =>
                {
                    if (!string.IsNullOrWhiteSpace(_assetsSettings.ApiKey))
                    {
                        builderConfigure = builderConfigure.WithApiKey(_assetsSettings.ApiKey);
                    }

                    return(builderConfigure);
                });

                builder.RegisterType <MtAssetPairsManager>()
                .AsSelf()
                .As <IAssetPairsManager>()
                .SingleInstance()
                .OnActivated(args => args.Instance.Start())
                .WithParameter(new TypedParameter(typeof(TimeSpan), _settings.AssetsCache.ExpirationPeriod));
            }
        }
        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>();

            LoadAzureRepositories(builder);

            _services.RegisterAssetsClient(
                AssetServiceSettings.Create(new Uri(_settings.AssetsServiceClient.ServiceUrl),
                                            TimeSpan.FromMinutes(3)));

            LoadAssetsCacheDictionaries(builder);

            LoadServices(builder);

            LoadRabbitSubscribers(builder);

            builder.Populate(_services);
        }
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <StartupManager>()
            .As <IStartupManager>();

            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(_settings.CurrentValue.AssetsServiceClient.ServiceUrl),
                                             _settings.CurrentValue.PayInvoicePortal.AssetsCacheExpirationPeriod));

            builder.RegisterInstance(new PayInvoiceClient(_settings.CurrentValue.PayInvoiceServiceClient))
            .As <IPayInvoiceClient>()
            .SingleInstance();

            builder.RegisterInstance(new PayAuthClient(_settings.CurrentValue.PayAuthServiceClient))
            .As <IPayAuthClient>()
            .SingleInstance();

            builder.RegisterInstance(new PayInternalClient(_settings.CurrentValue.PayInternalServiceClient))
            .As <IPayInternalClient>()
            .SingleInstance();

            builder.RegisterInstance(new EmailPartnerRouterClient(_settings.CurrentValue.EmailPartnerRouterServiceClient.ServiceUrl))
            .As <IEmailPartnerRouterClient>()
            .SingleInstance();

            builder.RegisterRateCalculatorClient(_settings.CurrentValue.RateCalculatorServiceClient.ServiceUrl);

            builder.RegisterPayMerchantClient(_settings.CurrentValue.PayMerchantServiceClient, null);

            builder.RegisterType <RealtimeNotificationsService>()
            .As <IRealtimeNotificationsService>()
            .SingleInstance();

            RegisterRabbitSubscribers(builder);
        }
Exemplo n.º 6
0
        private void RegisterClients(ContainerBuilder builder)
        {
            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(_settings.CurrentValue.AssetsServiceClient.ServiceUrl),
                                             _settings.CurrentValue.LiquidityEngineService.AssetsCacheExpirationPeriod));

            builder.RegisterBalancesClient(_settings.CurrentValue.BalancesServiceClient);

            builder.Register(container =>
                             new ExchangeOperationsServiceClient(_settings.CurrentValue.ExchangeOperationsServiceClient
                                                                 .ServiceUrl))
            .As <IExchangeOperationsServiceClient>()
            .SingleInstance();

            builder.RegisterB2С2RestClient(new B2C2ClientSettings(_settings.CurrentValue.B2C2Client.Url,
                                                                  _settings.CurrentValue.B2C2Client.AuthorizationToken));

            builder.RegisterLykkeServiceClient(_settings.CurrentValue.DwhServiceClient.ServiceUrl, null);

            MatchingEngineClientSettings matchingEngineClientSettings = _settings.CurrentValue.MatchingEngineClient;

            if (!IPAddress.TryParse(matchingEngineClientSettings.IpEndpoint.Host, out var address))
            {
                address = Dns.GetHostAddressesAsync(matchingEngineClientSettings.IpEndpoint.Host).Result[0];
            }

            var endPoint = new IPEndPoint(address, matchingEngineClientSettings.IpEndpoint.Port);

            builder.RegisterMeClient(endPoint);
        }
        private void BindClients(ContainerBuilder builder)
        {
            builder.RegisterAssetsClient(
                AssetServiceSettings.Create(new Uri(_settings.Assets.ServiceUrl),
                                            _jobSettings.AssetsCache.ExpirationPeriod));

            builder.RegisterType <PersonalDataService>()
            .As <IPersonalDataService>()
            .WithParameter(TypedParameter.From(_settings.PersonalDataServiceSettings));

            builder.RegisterLykkeServiceClient(_settings.ClientAccountClient.ServiceUrl);
            builder.RegisterOperationsClient(_settings.TransactionHandlerJob.Services.OperationsUrl);
            builder.RegisterExchangeOperationsClient(_jobSettings.ExchangeOperationsServiceUrl);

            builder.Register <IEthereumCoreAPI>(x =>
            {
                var api = new EthereumCoreAPI(new Uri(_settings.Ethereum.EthereumCoreUrl));
                api.SetRetryPolicy(null);
                return(api);
            }).SingleInstance();

            builder.RegisterOperationsRepositoryClients(_settings.OperationsRepositoryServiceClient);
            builder.RegisterBitcoinApiClient(_settings.BitCoinCore.BitcoinCoreApiUrl);

            builder.RegisterMeClient(_settings.MatchingEngineClient.IpEndpoint.GetClientIpEndPoint());
        }
Exemplo n.º 8
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <StartupManager>()
            .As <IStartupManager>();

            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(_settings.CurrentValue.AssetsServiceClient.ServiceUrl), TimeSpan.FromMinutes(3)));
        }
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterExchangeOperationsClient(_settings.CurrentValue.ExchangeOperationsServiceClient);

            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(_settings.CurrentValue.AssetsServiceClient.ServiceUrl),
                                             TimeSpan.FromMinutes(60)));
        }
Exemplo n.º 10
0
        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.RegisterInstance(_settings.CurrentValue.PaymentSettings)
            .As <PaymentSettings>()
            .SingleInstance();

            builder.RegisterAssemblyTypes(typeof(IService).Assembly)
            .Where(t => typeof(IService).IsAssignableFrom(t))
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();

            builder.RegisterAssemblyTypes(typeof(IComponent).Assembly)
            .Where(t => typeof(IComponent).IsAssignableFrom(t))
            .AsImplementedInterfaces()
            .InstancePerLifetimeScope();

            builder.RegisterInstance(_settings.CurrentValue.PaymentSettings);

            IServiceCollection services = new ServiceCollection();

            services.RegisterMtDataReaderClientsPair(
                _settings.CurrentValue.MarginSettings.DataReaderDemoApiUrl,
                _settings.CurrentValue.MarginSettings.DataReaderLiveApiUrl,
                _settings.CurrentValue.MarginSettings.DataReaderDemoApiKey,
                _settings.CurrentValue.MarginSettings.DataReaderLiveApiKey,
                "Lykke.Service.PaymentSystem");

            builder.RegisterLykkeServiceClient(_appSettings.ClientAccountServiceClient.ServiceUrl);

            builder.RegisterType <PersonalDataService>().As <IPersonalDataService>()
            .WithParameter(TypedParameter.From(_appSettings.PersonalDataServiceClient));

            builder.RegisterFeeCalculatorClient(_appSettings.FeeCalculatorServiceClient.ServiceUrl, _log);

            services.RegisterAssetsClient(
                AssetServiceSettings.Create(
                    new Uri(_appSettings.AssetsServiceClient.ServiceUrl),
                    TimeSpan.FromMinutes(1)),
                _log);

            builder.Populate(services);

            base.Load(builder);
        }
        private void RegisterAssets(ContainerBuilder builder)
        {
            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(_assetSettings.ServiceUrl),
                                             _settings.AssetsCache.ExpirationPeriod));

            builder.RegisterType <AssetPairsManager>()
            .As <IAssetPairsManager>();
        }
        private void RegisterAssets(ContainerBuilder builder)
        {
            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(_settings.CurrentValue.Assets.ServiceUrl),
                                             _settings.CurrentValue.Assets.CacheExpirationPeriod));

            builder.RegisterType <AssetPairsManager>()
            .As <IAssetPairsManager>()
            .SingleInstance();
        }
Exemplo n.º 13
0
        protected override void Load(ContainerBuilder builder)
        {
            var services = new ServiceCollection();

            services.RegisterAssetsClient(AssetServiceSettings.Create(
                                              new Uri(_settings.CurrentValue.Assets.ServiceUrl),
                                              _settings.CurrentValue.Assets.CacheExpirationPeriod));

            builder.Populate(services);

            builder.RegisterLykkeServiceClient(_settings.CurrentValue.ClientAccountServiceClient.ServiceUrl);
        }
Exemplo n.º 14
0
        public AutofacModule(
            PersonalDataServiceClientSettings personalDataServiceClientSettings,
            AssetsServiceClientSettings assetsServiceClientSettings,
            TimeSpan assetsCacheExpirationPeriod,
            IServiceCollection services,
            ILog log)
        {
            _personalDataServiceClientSettings = personalDataServiceClientSettings;
            _log = log;

            services.RegisterAssetsClient(AssetServiceSettings.Create(
                                              new Uri(assetsServiceClientSettings.ServiceUrl), assetsCacheExpirationPeriod));
        }
Exemplo n.º 15
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <HealthService>()
            .As <IHealthService>()
            .SingleInstance();

            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(_settings.CurrentValue.AssetsServiceClient.ServiceUrl), TimeSpan.FromMinutes(3)));
            builder.AddTriggers();

            builder.RegisterType <UpdateBalanceFunctions>().SingleInstance();
            builder.RegisterType <UpdateObservableOperations>().SingleInstance();
        }
        protected override void Load(ContainerBuilder builder)
        {
            var inMemoryCacheOptions = Options.Create(new MemoryDistributedCacheOptions());
            IDistributedCache cache  = new MemoryDistributedCache(inMemoryCacheOptions);

            builder.RegisterInstance(cache)
            .As <IDistributedCache>()
            .SingleInstance();

            #region Repo

            builder.Register(c => BlackListRepository.Create(_settings.ConnectionString(x => x.BlockchainCashoutPreconditionsCheckService.Db.DataConnString)
                                                             , c.Resolve <ILogFactory>()))
            .As <IBlackListRepository>()
            .SingleInstance();

            #endregion

            builder.RegisterType <AddressExtensionService>()
            .As <AddressExtensionService>()
            .WithParameter("cacheTime", TimeSpan.FromHours(12))
            .SingleInstance();

            builder.RegisterType <BlackListService>()
            .As <IBlackListService>()
            .SingleInstance();

            builder.RegisterType <HealthService>()
            .As <IHealthService>()
            .SingleInstance();

            builder.RegisterType <StartupManager>()
            .As <IStartupManager>();

            builder.RegisterType <ShutdownManager>()
            .As <IShutdownManager>();

            builder.Register(c =>
                             new BlockchainWalletsClient(_settings.CurrentValue.BlockchainWalletsServiceClient.ServiceUrl, c.Resolve <ILogFactory>()))
            .As <IBlockchainWalletsClient>()
            .SingleInstance();

            builder.RegisterType <ValidationService>()
            .As <IValidationService>().SingleInstance();

            builder.RegisterAssetsClient(
                AssetServiceSettings.Create(new Uri(_settings.CurrentValue.Assets.ServiceUrl),
                                            _settings.CurrentValue.Assets.CacheExpirationPeriod),
                true
                );
        }
Exemplo n.º 17
0
        private void RegisterServiceClients(ContainerBuilder builder, AppSettings appSettings)
        {
            builder.RegisterType <NettingEngineInstanceManager>()
            .WithParameter(TypedParameter.From(appSettings.NettingEngineServiceClient.Instances))
            .As <INettingEngineInstanceManager>()
            .SingleInstance();

            builder.RegisterInstance(
                new AssetsService(new Uri(appSettings.AssetsServiceClient.ServiceUrl)))
            .As <IAssetsService>()
            .SingleInstance();

            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(appSettings.AssetsServiceClient.ServiceUrl),
                                             appSettings.TelegramReporterService.AssetsCacheExpirationPeriod));

            builder.RegisterBalancesClient(appSettings.BalancesServiceClient.ServiceUrl);
            builder.RegisterMarketMakerReportsClient(appSettings.MarketMakerReportsServiceClient, null);

            RegisterFiatMarketMakerReportsClient(builder,
                                                 appSettings.FiatMarketMakerReportsServiceClient);

            builder.RegisterMarketMakerArbitrageDetectorClient(new MarketMakerArbitrageDetectorServiceClientSettings
            {
                ServiceUrl = appSettings.MarketMakerArbitrageDetectorServiceClient.ServiceUrl
            }, null);

            builder.RegisterInstance(
                new LiquidityEngineUrlSettings(appSettings.LiquidityEngineServiceClient.Instances
                                               .Select(e => e.ServiceUrl).ToArray()))
            .SingleInstance();

            builder.RegisterIndexHedgingEngineClient(appSettings.IndexHedgingEngineClient, null);

            var cryptoIndexInstances = new List <CryptoIndexClientSettings>();

            foreach (var cics in appSettings.CryptoIndexServiceClient.Instances)
            {
                cryptoIndexInstances.Add(new CryptoIndexClientSettings
                {
                    DisplayName = cics.DisplayName, ServiceUrl = cics.ServiceUrl
                });
            }
            builder.RegisterInstance(
                new CryptoIndexInstancesSettings
            {
                Instances = cryptoIndexInstances.ToArray()
            })
            .SingleInstance();
        }
Exemplo n.º 18
0
        private void BuildConfiguration(IServiceCollection services)
        {
            var generalSettings = Configuration.LoadSettings <Settings>();

            services.AddSingleton(generalSettings.CurrentValue);
            _settings = generalSettings.CurrentValue;

            services.RegisterAssetsClient(AssetServiceSettings.Create(new Uri(_settings.AssetsServiceClient.ServiceUrl), TimeSpan.FromMinutes(10)));
            services.AddSingleton <ILykkeMarketProfile>(new LykkeMarketProfile(new Uri(_settings.MarketProfileServiceClient.ServiceUrl)));

            services.AddSingleton(_settings.PayServiceRates);
            services.AddSingleton(new HttpClient());
            services.RegisterRepositories(_settings.PayServiceRates.Db.AssertHistoryConnString, (ILog)null);
        }
Exemplo n.º 19
0
        protected override void Load(ContainerBuilder builder)
        {
            _services.RegisterAssetsClient(AssetServiceSettings.Create(
                                               new Uri(_settings.CurrentValue.MarginTradingMarketMaker.ExternalServices.AssetsServiceUrl),
                                               TimeSpan.FromMinutes(5)));

            builder.RegisterInstance(
                new Candleshistoryservice(new Uri(_settings.CurrentValue.CandlesHistoryServiceClient.ServiceUrl)))
            .As <ICandleshistoryservice>()
            .SingleInstance();

            _services.AddSingleton <ITelemetryInitializer, UserAgentTelemetryInitializer>();

            builder.Populate(_services);
        }
Exemplo n.º 20
0
        protected override void Load(ContainerBuilder builder)
        {
            _services.RegisterAssetsClient(
                AssetServiceSettings.Create(
                    new Uri(_settings.AssetsServiceClient.ServiceUrl),
                    TimeSpan.FromMinutes(5)),
                _log);

            builder.RegisterType <PersonalDataService>()
            .As <IPersonalDataService>()
            .WithParameter(TypedParameter.From(_settings.PersonalDataServiceClient));

            builder.RegisterLykkeServiceClient(_settings.ClientAccountServiceClient.ServiceUrl);

            builder.Populate(_services);
        }
Exemplo n.º 21
0
        protected override void Load(ContainerBuilder builder)
        {
            var services = new ServiceCollection();

            services.RegisterAssetsClient(AssetServiceSettings.Create(
                                              new Uri(_settings.CurrentValue.Assets.ServiceUrl),
                                              _settings.CurrentValue.Assets.CacheExpirationPeriod));

            builder.RegisterType <ExchangeConnectorService>()
            .As <IExchangeConnectorService>()
            .WithParameter("settings", _settings.CurrentValue.MtStpExchangeConnectorClient)
            .SingleInstance();

            builder.Populate(services);

            builder.RegisterLykkeServiceClient(_settings.CurrentValue.ClientAccountServiceClient.ServiceUrl);
        }
Exemplo n.º 22
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterLykkeServiceClient(_serviceSettings.CurrentValue.ClientAccountServiceUrl);

            builder.RegisterType <HftInternalServiceAPI>()
            .As <IHftInternalServiceAPI>()
            .WithParameter("baseUri", new Uri(_serviceSettings.CurrentValue.HftInternalServiceUrl));

            builder.RegisterType <LykkeMarketProfileServiceAPI>()
            .As <ILykkeMarketProfileServiceAPI>()
            .WithParameter("baseUri", new Uri(_serviceSettings.CurrentValue.MarketProfileUrl));

            builder.RegisterOperationsClient(_serviceSettings.CurrentValue.OperationsUrl);

            builder.RegisterType <LykkeRegistrationClient>()
            .As <ILykkeRegistrationClient>()
            .WithParameter("serviceUrl", _serviceSettings.CurrentValue.RegistrationUrl);

            builder.RegisterType <ClientSessionsClient>()
            .As <IClientSessionsClient>()
            .WithParameter("serviceUrl", _serviceSettings.CurrentValue.SessionUrl);

            builder.RegisterType <PersonalDataService>().As <IPersonalDataService>()
            .WithParameter(TypedParameter.From(_apiSettings.CurrentValue.PersonalDataServiceSettings));

            builder.RegisterOperationsHistoryClient(_apiSettings.CurrentValue.OperationsHistoryServiceClient, _log);

            _services.RegisterAssetsClient(AssetServiceSettings.Create(
                                               new Uri(_serviceSettings.CurrentValue.AssetsServiceUrl),
                                               TimeSpan.FromMinutes(1)));

            builder.RegisterClientDictionariesClient(_apiSettings.CurrentValue.ClientDictionariesServiceClient, _log);

            builder.BindMeClient(_apiSettings.CurrentValue.MatchingEngineClient.IpEndpoint.GetClientIpEndPoint(), socketLog: null, ignoreErrors: true);

            builder.RegisterOperationsRepositoryClients(_serviceSettings.CurrentValue.OperationsRepositoryClient, _log);

            builder.RegisterAffiliateClient(_serviceSettings.CurrentValue.AffiliateServiceClient.ServiceUrl, _log);

            builder.RegisterFeeCalculatorClient(_apiSettings.CurrentValue.FeeCalculatorServiceClient.ServiceUrl, _log);

            builder.Populate(_services);
        }
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterModule(new Services.AutofacModule());

            builder.RegisterModule(new AzureRepositories.AutofacModule(
                                       _appSettings.Nested(o => o.MarketMakerReportsService.Db.DataConnectionString)));

            builder.RegisterType <StartupManager>()
            .As <IStartupManager>();

            builder.RegisterType <ShutdownManager>()
            .As <IShutdownManager>();

            RegisterRabbit(builder);

            builder.RegisterRateCalculatorClient(_appSettings.CurrentValue.RateCalculatorServiceClient.ServiceUrl);

            builder.RegisterAssetsClient(AssetServiceSettings
                                         .Create(new Uri(_appSettings.CurrentValue.AssetsServiceClient.ServiceUrl),
                                                 _appSettings.CurrentValue.MarketMakerReportsService.AssetsCacheExpirationPeriod));
        }
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <StartupManager>()
            .As <IStartupManager>()
            .SingleInstance();

            builder.RegisterType <ShutdownManager>()
            .As <IShutdownManager>()
            .AutoActivate()
            .SingleInstance();

            builder.RegisterInstance(
                new Swisschain.Sirius.Api.ApiClient.ApiClient(_appSettings.CurrentValue.SiriusApiServiceClient.GrpcServiceUrl, _appSettings.CurrentValue.SiriusApiServiceClient.ApiKey)
                ).As <Swisschain.Sirius.Api.ApiClient.IApiClient>();

            builder.RegisterType <DepositsDetectorService>()
            .WithParameter(TypedParameter.From(_appSettings.CurrentValue.SiriusApiServiceClient.BrokerAccountId))
            .As <IStartable>()
            .As <IStopable>()
            .AutoActivate()
            .SingleInstance();

            builder.Register(ctx =>
                             new LastCursorRepository(AzureTableStorage <CursorEntity> .Create(
                                                          _appSettings.ConnectionString(x => x.SiriusDepositsDetectorJob.Db.DataConnString),
                                                          "LastDepostCursors", ctx.Resolve <ILogFactory>()))
                             ).As <ILastCursorRepository>().SingleInstance();

            builder.Register(ctx =>
                             new OperationIdsRepository(AzureTableStorage <OperationIdEntity> .Create(
                                                            _appSettings.ConnectionString(x => x.SiriusDepositsDetectorJob.Db.DataConnString),
                                                            "OperationIds", ctx.Resolve <ILogFactory>()))
                             ).As <IOperationIdsRepository>().SingleInstance();

            builder.RegisterMeClient(_appSettings.CurrentValue.MatchingEngineClient.IpEndpoint.GetClientIpEndPoint(), true);
            builder.RegisterAssetsClient(
                AssetServiceSettings.Create(
                    new Uri(_appSettings.CurrentValue.AssetsServiceClient.ServiceUrl),
                    _appSettings.CurrentValue.AssetsServiceClient.ExpirationPeriod));
        }
        protected override void Load(ContainerBuilder builder)
        {
            builder.Register(c =>
                             new ClientDialogsRepository(AzureTableStorage <ClientDialogEntity> .Create(
                                                             _appSettings.ConnectionString(x => x.ClientDialogsService.Db.DataConnString), "Dialogs", c.Resolve <ILogFactory>()),
                                                         AzureTableStorage <AzureIndex> .Create(_appSettings.ConnectionString(x => x.ClientDialogsService.Db.DataConnString),
                                                                                                "ClientDialogs", c.Resolve <ILogFactory>()),
                                                         AzureTableStorage <AzureIndex> .Create(_appSettings.ConnectionString(x => x.ClientDialogsService.Db.DataConnString),
                                                                                                "GlobalDialogs", c.Resolve <ILogFactory>())
                                                         )
                             ).As <IClientDialogsRepository>().SingleInstance();

            builder.Register(c =>
                             new ClientDialogSubmitsRepository(AzureTableStorage <ClientDialogSubmitEntity> .Create(
                                                                   _appSettings.ConnectionString(x => x.ClientDialogsService.Db.DataConnString), "SubmittedDialogs",
                                                                   c.Resolve <ILogFactory>()))
                             ).As <IClientDialogSubmitsRepository>().SingleInstance();

            builder.Register(c =>
                             new DialogConditionsRepository(AzureTableStorage <DialogConditionEntity> .Create(
                                                                _appSettings.ConnectionString(x => x.ClientDialogsService.Db.DataConnString), "DialogConditions", c.Resolve <ILogFactory>()),
                                                            AzureTableStorage <AzureIndex> .Create(_appSettings.ConnectionString(x => x.ClientDialogsService.Db.DataConnString),
                                                                                                   "DialogConditions", c.Resolve <ILogFactory>())
                                                            )
                             ).As <IDialogConditionsRepository>().SingleInstance();

            builder.RegisterType <ClientDialogsService>()
            .As <IClientDialogsService>()
            .SingleInstance();

            builder.RegisterType <DialogConditionsService>()
            .As <IDialogConditionsService>()
            .SingleInstance();

            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(_appSettings.CurrentValue.AssetsServiceClient.ServiceUrl),
                                             _appSettings.CurrentValue.AssetsServiceClient.ExpirationPeriod));
        }
Exemplo n.º 26
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterClientAccountClient(_settings.ClientAccountServiceUrl);

            builder.RegisterHftInternalClient(_settings.HftInternalServiceUrl);

            builder.RegisterType <LykkeMarketProfileServiceAPI>()
            .As <ILykkeMarketProfileServiceAPI>()
            .WithParameter("baseUri", new Uri(_settings.MarketProfileUrl));

            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);

            builder.Populate(_services);
        }
Exemplo n.º 27
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterAssetsClient(AssetServiceSettings.Create(new Uri(_settings.CurrentValue.AssetsServiceClient.ServiceUrl), TimeSpan.FromMinutes(3)));

            builder.RegisterHistoryClient(_settings.CurrentValue.HistoryServiceClient);
        }
Exemplo n.º 28
0
        protected override void Load(ContainerBuilder builder)
        {
            builder
            .Register(ctx => _blockchainsIntegrationSettings)
            .AsSelf()
            .SingleInstance();

            builder
            .Register(CreateBlockchainSignFacadeClient)
            .As <IBlockchainSignFacadeClient>();

            builder
            .RegisterType <BlockchainIntegrationService>()
            .WithParameter("timeoutFoApiInSeconds", _blockchainWalletsSettings.BlockchainApiTimeoutInSeconds)
            .As <IBlockchainIntegrationService>()
            .SingleInstance();

            builder
            .RegisterType <HealthService>()
            .As <IHealthService>();

            builder
            .RegisterType <WalletService>()
            .As <IWalletService>();

            builder
            .RegisterType <AddressService>()
            .As <IAddressService>()
            .SingleInstance();

            builder
            .RegisterType <BlockchainExtensionsService>()
            .As <IBlockchainExtensionsService>()
            .SingleInstance();

            builder
            .RegisterType <BlockchainAssetService>()
            .As <IBlockchainAssetService>()
            .SingleInstance();

            builder
            .RegisterType <AddressParser>()
            .As <IAddressParser>();

            builder
            .RegisterAssetsClient(AssetServiceSettings.Create(
                                      new Uri(_assetServiceSettings.ServiceUrl),
                                      _assetServiceSettings.ExpirationPeriod));

            builder
            .RegisterType <StartupManager>()
            .As <IStartupManager>();

            #region FirstGenerationServices

            builder
            .RegisterType <LegacyWalletService>()
            .As <ILegacyWalletService>();

            builder
            .RegisterType <SrvBlockchainHelper>()
            .As <ISrvBlockchainHelper>();

            builder
            .RegisterType <SrvEthereumHelper>()
            .As <ISrvEthereumHelper>();

            builder
            .RegisterType <SrvSolarCoinHelper>()
            .As <ISrvSolarCoinHelper>();

            builder.RegisterInstance <BitcoinCoreSettings>(_appSettings.BitcoinCoreSettings);
            builder.RegisterInstance <IBitcoinApiClient>(new BitcoinApiClient(_appSettings.BitcoinCoreSettings.BitcoinCoreApiUrl));
            builder.RegisterLykkeServiceClient(_appSettings.ClientAccountServiceClient.ServiceUrl);
            builder.RegisterInstance <IEthereumCoreAPI>(new EthereumCoreAPI(new Uri(_appSettings.EthereumServiceClient.ServiceUrl), new HttpClient()));
            builder.RegisterInstance <SolarCoinServiceClientSettings>(_appSettings.SolarCoinServiceClient);
            builder.RegisterInstance <QuantaServiceClientSettings>(_appSettings.QuantaServiceClient);
            builder.RegisterInstance <ChronoBankServiceClientSettings>(_appSettings.ChronoBankServiceClient);

            #endregion
        }
Exemplo n.º 29
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.Register(ctx =>
                {
                    var factory = ctx.Resolve<IHttpClientFactory>();
                    return new LykkeWalletAPIv1Client(factory.CreateClient(HttpClientNames.WalletApiV1));
                })
                .As<ILykkeWalletAPIv1Client>();

            builder.Register(ctx =>
                {
                    var factory = ctx.Resolve<IHttpClientFactory>();
                    return new LykkeWalletAPIv2Client(factory.CreateClient(HttpClientNames.WalletApiV2));
                })
                .As<ILykkeWalletAPIv2Client>();

            builder.RegisterClientSessionClient(
                new SessionServiceClientSettings {ServiceUrl = _config.Services.SessionServiceUrl});

            builder.RegisterType<GrpcPrincipal>().As<IGrpcPrincipal>().InstancePerLifetimeScope();

            builder.Register(ctx =>
                {
                    var logger = ctx.Resolve<ILoggerFactory>();
                    _logFactory = logger.ToLykke();
                    return _logFactory;
                })
                .As<ILogFactory>();

            builder.Register(ctx =>
                {
                    var client = new MyNoSqlTcpClient(() => _config.MyNoSqlServer.ReaderServiceUrl,
                        $"{ApplicationInformation.AppName}-{Environment.MachineName}");

                    client.Start();
                    return client;
                })
                .AsSelf()
                .SingleInstance();

            builder.Register(ctx =>
                    new MyNoSqlReadRepository<PriceEntity>(ctx.Resolve<MyNoSqlTcpClient>(),
                        _config.MyNoSqlServer.PricesTableName)
                )
                .As<IMyNoSqlServerDataReader<PriceEntity>>()
                .SingleInstance();

            builder.Register(ctx =>
                    new MyNoSqlReadRepository<CandleEntity>(ctx.Resolve<MyNoSqlTcpClient>(),
                        _config.MyNoSqlServer.CandlesTableName)
                )
                .As<IMyNoSqlServerDataReader<CandleEntity>>()
                .SingleInstance();

            builder.Register(ctx =>
                    new MyNoSqlReadRepository<TickerEntity>(ctx.Resolve<MyNoSqlTcpClient>(),
                        _config.MyNoSqlServer.TickersTableName)
                )
                .As<IMyNoSqlServerDataReader<TickerEntity>>()
                .SingleInstance();

            builder.Register(ctx =>
                new MyNoSqlReadRepository<OrderbookEntity>(ctx.Resolve<MyNoSqlTcpClient>(),
                    _config.MyNoSqlServer.OrderbooksTableName)
            ).As<IMyNoSqlServerDataReader<OrderbookEntity>>().SingleInstance();

            builder.Register(ctx =>
                new MyNoSqlReadRepository<SessionEntity>(ctx.Resolve<MyNoSqlTcpClient>(),
                    _config.MyNoSqlServer.SessionsTableName)
            ).As<IMyNoSqlServerDataReader<SessionEntity>>().SingleInstance();

            builder.Register(ctx =>
            {
                return new MyNoSqlServer.DataWriter.MyNoSqlServerDataWriter<SessionEntity>(() =>
                        _config.MyNoSqlServer.WriterServiceUrl,
                    _config.MyNoSqlServer.SessionsTableName);
            }).As<IMyNoSqlServerDataWriter<SessionEntity>>().SingleInstance();

            builder.RegisterType<PricesStreamService>()
                .WithParameter(TypedParameter.From(true))
                .WithParameter("jobPeriod", TimeSpan.FromSeconds(1))
                .AsSelf()
                .SingleInstance();

            builder.RegisterType<CandlesStreamService>()
                .WithParameter(TypedParameter.From(true))
                .AsSelf()
                .SingleInstance();

            builder.RegisterType<OrderbookStreamService>()
                .WithParameter(TypedParameter.From(true))
                .AsSelf()
                .SingleInstance();

            builder.RegisterType<PublicTradesStreamService>()
                .WithParameter(TypedParameter.From(true))
                .AsSelf()
                .SingleInstance();

            builder.RegisterType<ApplicationManager>()
                .As<IStartable>()
                .AutoActivate()
                .SingleInstance();

            builder.RegisterInstance(
                    new Candleshistoryservice(new Uri(_config.Services.CandlesHistoryServiceUrl), new HttpClient())
                )
                .As<ICandleshistoryservice>();

            builder.RegisterAssetsClient(AssetServiceSettings.Create(new Uri(_config.Services.AssetsServiceUrl),
                TimeSpan.FromMinutes(60)));

            builder.RegisterBalancesClient(_config.Services.BalancesServiceUrl);
            builder.RegisterMeClient(_config.MatchingEngine.GetIpEndPoint());
            builder.RegisterClientAccountClient(_config.Services.ClientAccountServiceUrl);

            builder.RegisterType<AssetsHelper>().AsSelf().SingleInstance();
            builder.RegisterType<ValidationService>().AsSelf().SingleInstance();
            builder.RegisterInstance(_config.WalletApi);
            builder.RegisterRateCalculatorClient(_config.Services.RateCalculatorServiceUrl);
            var cache = new RedisCache(new RedisCacheOptions
            {
                Configuration = _config.Redis.RedisConfiguration,
                InstanceName = _config.Redis.InstanceName
            });

            builder.RegisterInstance(cache)
                .As<IDistributedCache>()
                .SingleInstance();

            builder.RegisterType<OrderbooksService>()
                .WithParameter(TypedParameter.From(_config.Redis.OrderBooksCacheKeyPattern))
                .AsSelf()
                .SingleInstance();

            builder.Register(ctx =>
                    new TradesAdapterClient(_config.Services.TradesAdapterServiceUrl,
                        ctx.Resolve<ILogFactory>().CreateLog(nameof(TradesAdapterClient)))
                )
                .As<ITradesAdapterClient>()
                .SingleInstance();

            builder.RegisterRegistrationServiceClient(new RegistrationServiceClientSettings{ServiceUrl = _config.Services.RegistrationServiceUrl});

            builder.RegisterType<SessionService>()
                .WithParameter(TypedParameter.From(_config.SessionLifetimeInMins))
                .AsSelf()
                .SingleInstance();

            builder.RegisterType<PublicTradesSubscriber>()
                .As<IStartable>()
                .AutoActivate()
                .WithParameter("connectionString", _config.RabbitMq.PublicTrades.ConnectionString)
                .WithParameter("exchangeName", _config.RabbitMq.PublicTrades.ExchangeName)
                .SingleInstance();

            builder.RegisterPushNotificationsClient(_config.Services.PushNotificationsServiceUrl);
        }
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <HealthService>()
            .As <IHealthService>()
            .SingleInstance();

            builder.RegisterType <StartupManager>()
            .As <IStartupManager>()
            .SingleInstance();

            builder.RegisterType <ShutdownManager>()
            .As <IShutdownManager>()
            .AutoActivate()
            .SingleInstance();

            builder.RegisterType <CashoutProcessorService>()
            .WithParameter(TypedParameter.From(_settings.CurrentValue.SiriusApiServiceClient.BrokerAccountId))
            .As <IStartable>()
            .As <IStopable>()
            .AutoActivate()
            .SingleInstance();

            builder.RegisterInstance(
                new Swisschain.Sirius.Api.ApiClient.ApiClient(_settings.CurrentValue.SiriusApiServiceClient.GrpcServiceUrl, _settings.CurrentValue.SiriusApiServiceClient.ApiKey)
                ).As <Swisschain.Sirius.Api.ApiClient.IApiClient>();

            builder.Register(ctx =>
                             new LastCursorRepository(AzureTableStorage <CursorEntity> .Create(
                                                          _settings.ConnectionString(x => x.SiriusCashoutProcessorJob.Db.DataConnString),
                                                          "LastWithdrawalCursors", ctx.Resolve <ILogFactory>()))
                             ).As <ILastCursorRepository>().SingleInstance();

            builder.Register(ctx =>
                             new WithdrawalLogsRepository(AzureTableStorage <WithdrawalLogEntity> .Create(
                                                              _settings.ConnectionString(x => x.SiriusCashoutProcessorJob.Db.DataConnString),
                                                              "WithdrawalStateLogs", ctx.Resolve <ILogFactory>()))
                             ).As <IWithdrawalLogsRepository>().SingleInstance();

            builder.Register(ctx =>
                             new RefundsRepository(AzureTableStorage <RefundEntity> .Create(
                                                       _settings.ConnectionString(x => x.SiriusCashoutProcessorJob.Db.DataConnString),
                                                       "WithdrawalRefunds", ctx.Resolve <ILogFactory>()))
                             ).As <IRefundsRepository>().SingleInstance();

            builder.RegisterMeClient(_settings.CurrentValue.MatchingEngineClient.IpEndpoint.GetClientIpEndPoint(), true);
            builder.RegisterAssetsClient(
                AssetServiceSettings.Create(
                    new Uri(_settings.CurrentValue.AssetsServiceClient.ServiceUrl),
                    _settings.CurrentValue.AssetsServiceClient.ExpirationPeriod));

            builder.RegisterOperationsClient(_settings.CurrentValue.OperationsServiceClient.ServiceUrl);

            builder.RegisterType <PrivateKeyService>()
            .WithParameter(new NamedParameter("vaultBaseUrl", _settings.CurrentValue.SiriusCashoutProcessorJob.KeyVault.VaultBaseUrl))
            .WithParameter(new NamedParameter("keyName", _settings.CurrentValue.SiriusCashoutProcessorJob.KeyVault.PrivateKeyName))
            .SingleInstance();

            builder.RegisterInstance(
                new KeyVaultClient(
                    async(string authority, string resource, string scope) =>
            {
                var authContext = new AuthenticationContext(authority);
                var clientCred  = new ClientCredential(_settings.CurrentValue.SiriusCashoutProcessorJob.KeyVault.ClientId,
                                                       _settings.CurrentValue.SiriusCashoutProcessorJob.KeyVault.ClientSecret);
                var result = await authContext.AcquireTokenAsync(resource, clientCred);
                if (result == null)
                {
                    throw new InvalidOperationException("Failed to retrieve access token for Key Vault");
                }

                return(result.AccessToken);
            }
                    ));
        }