Esempio n. 1
0
        public void ConfigureServices(IServiceCollection services)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.Configuration(Configuration)
                         .CreateLogger();
            logger = Log.Logger;
            logger.Information("Logger created");
            Config.ConnectionStrings connectionStrings = new Config.ConnectionStrings();
            Configuration.GetSection("ConnectionStrings").Bind(connectionStrings);
#if DEBUG
            logger.Debug("ConnectionString: " + connectionStrings.DemoExchangeDb);
#endif
            var httpHandler = new HttpClientHandler {
                ServerCertificateCustomValidationCallback =
                    HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
            };
            var channel = GrpcChannel.ForAddress("https://172.17.0.1:8091",
                                                 new GrpcChannelOptions {
                HttpHandler = httpHandler
            });

            services.AddControllers();
            services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title          = "DemoExchange.OrderService",
                    Version        = "v1",
                    Description    = "API for DemoExchange",
                    TermsOfService = new Uri("https://er-x.io/terms"),
                    Contact        = new OpenApiContact {
                        Name  = "ER-X",
                        Email = string.Empty,
                        Url   = new Uri("https://er-x.io"),
                    },
                    License = new OpenApiLicense {
                        Name = "Use under LICX",
                        Url  = new Uri("https://er-x.io/license"),
                    }
                });

                /* Set the comments path for the Swagger JSON and UI.
                 * var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                 * var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                 * c.IncludeXmlComments(xmlPath);*/
            });
            services.AddSingleton <Config.ConnectionStrings>(connectionStrings);
            services.AddSingleton <IDemoExchangeDbContextFactory <OrderContext>, OrderContextFactory>();
            services.AddSingleton <IOrderService, DemoExchange.Services.OrderService>();
            services.AddSingleton <IAccountServiceRpcClient>(new AccountServiceRpcClient(channel));

            logger.Information("ConfigureServices done");
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureStorageQueueSmsRelay"/> class.
        /// </summary>
        /// <param name="azureConfigOptions"> the azure configuration options </param>
        /// <param name="dataConfigOptions"> the database configuration options </param>
        /// <param name="notifyConfigOptions"> the Notify service configuration options </param>
        /// <param name="connectionStringsOptions"> the connections strings options </param>
        public AzureStorageQueueSmsRelay(
            IOptions <AzureConfiguration> azureConfigOptions,
            IOptions <DataConfiguration> dataConfigOptions,
            IOptions <NotifyConfiguration> notifyConfigOptions,
            IOptions <ConnectionStrings> connectionStringsOptions)
        {
            this.azureConfig       = azureConfigOptions.Value;
            this.dataConfig        = dataConfigOptions.Value;
            this.notifyConfig      = notifyConfigOptions.Value;
            this.connectionStrings = connectionStringsOptions.Value;

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionStrings.StorageAccount);

            this.queueClient = storageAccount.CreateCloudQueueClient();
        }
Esempio n. 3
0
        public void ConfigureServices(IServiceCollection services)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.Configuration(Configuration)
                         .CreateLogger();
            Logger.Here().Information("Logger created");

            Config.ConnectionStrings connectionStrings = new Config.ConnectionStrings();
            Configuration.GetSection(Config.ConnectionStrings.SECTION).Bind(connectionStrings);
#if DEBUG
            Logger.Here().Debug("Redis: " + connectionStrings.Redis);
#endif
            ConnectionMultiplexer muxer      = ConnectionMultiplexer.Connect(connectionStrings.Redis);
            IDatabase             redis      = muxer.GetDatabase();
            ISubscriber           subscriber = muxer.GetSubscriber();

            Logger.Here().Information("Subscribing to " + Constants.PubSub.TOPIC_TRANSACTION_PROCESSED);
            subscriber.Subscribe(Constants.PubSub.TOPIC_TRANSACTION_PROCESSED,
                                 Handlers.TransactionProcessHandler(Logger, redis));

            Config.ErxServices erx = new Config.ErxServices();
            Configuration.GetSection(Config.ErxServices.SECTION).Bind(erx);
#if DEBUG
            Logger.Here().Debug("OrderUrlBase: " + erx.OrderUrlBase);
#endif

            var httpHandler = new HttpClientHandler()
            {
                ServerCertificateCustomValidationCallback =
                    HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
            };
            var channel = GrpcChannel.ForAddress(erx.OrderUrlBase,
                                                 new GrpcChannelOptions {
                HttpHandler = httpHandler
            });

            services.AddGrpc();
            services.AddSingleton <IDatabase>(redis);
            services.AddSingleton <IOrderServiceRpcClient>(new OrderServiceRpcClient(channel));

            Logger.Here().Information("END");
        }
Esempio n. 4
0
        public void ConfigureServices(IServiceCollection services)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.Configuration(Configuration)
                         .CreateLogger();
            Logger.Here().Information("Logger created");

            Config.ConnectionStrings connectionStrings = new Config.ConnectionStrings();
            Configuration.GetSection(Config.ConnectionStrings.SECTION).Bind(connectionStrings);
#if DEBUG
            Logger.Here().Debug("DemoExchangeDb: " + connectionStrings.DemoExchangeDb);
#endif

            services.AddGrpc();
            services.AddSingleton <Config.ConnectionStrings>(connectionStrings);
            services.AddSingleton <IDemoExchangeDbContextFactory <AccountContext>, AccountContextFactory>();
            services.AddSingleton <IAccountService, DemoExchange.Services.AccountService>();

            Logger.Here().Information("END");
        }
Esempio n. 5
0
        public void ConfigureServices(IServiceCollection services)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.Configuration(Configuration)
                         .CreateLogger();
            Logger.Here().Information("Logger created");

            Config.ConnectionStrings connectionStrings = new Config.ConnectionStrings();
            Configuration.GetSection(Config.ConnectionStrings.SECTION).Bind(connectionStrings);
#if DEBUG
            Logger.Here().Debug("DemoExchangeDb: " + connectionStrings.DemoExchangeDb);
            Logger.Here().Debug("Redis: " + connectionStrings.Redis);
#endif
            ConnectionMultiplexer muxer      = ConnectionMultiplexer.Connect(connectionStrings.Redis);
            ISubscriber           subscriber = muxer.GetSubscriber();

            Config.ErxServices erx = new Config.ErxServices();
            Configuration.GetSection(Config.ErxServices.SECTION).Bind(erx);
#if DEBUG
            Logger.Here().Debug("AccountUrlBase: " + erx.AccountUrlBase);
#endif

            var httpHandler = new HttpClientHandler()
            {
                ServerCertificateCustomValidationCallback =
                    HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
            };
            var channel = GrpcChannel.ForAddress(erx.AccountUrlBase,
                                                 new GrpcChannelOptions {
                HttpHandler = httpHandler
            });

            services.AddGrpc();
            services.AddSingleton <Config.ConnectionStrings>(connectionStrings);
            services.AddSingleton <IDemoExchangeDbContextFactory <OrderContext>, OrderContextFactory>();
            services.AddSingleton <ISubscriber>(subscriber);
            services.AddSingleton <IOrderService, DemoExchange.Services.OrderService>();
            services.AddSingleton <IAccountServiceRpcClient>(new AccountServiceRpcClient(channel));

            Logger.Here().Information("END");
        }