Пример #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddOptions();
            services.AddJob <StatsLoaderJob>();

            services.AddConfiguration <JobConfiguration>("JobConfiguration");
            services.AddConfiguration <WorkerConfiguration>("WorkerConfiguration");
            services.AddConfiguration <MongoDbConfiguration>("DataConfiguration");

            services.AddSingleton <IETLService, ETLService>();
            services.AddSingleton <IPUBGApiCaller, PUBGApiCaller>();
            services.AddSingleton <IReadOnlyMongoDbService, ReadOnlyMongoDbService>();
            services.AddSingleton <IWriteOnlyMongoDbService, WriteOnlyMongoDbService>();
            services.AddSingleton <IDocumentExtractorService, DocumentExtractorService>();

            services.AddSingleton((collection) =>
            {
                HttpClient httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",
                                                                                               collection.GetService <IOptions <WorkerConfiguration> >().Value.PUBGApiKey);
                httpClient.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/vnd.api+json"));

                return(httpClient);
            });

            CallGovernor.Init();
        }
 public CallGovernorTests()
 {
     CallGovernor.Init();
 }