Browse Source

More tweaks

pull/2106/head
David Fowler 1 year ago
parent
commit
e9dba5781f
6 changed files with 19 additions and 35 deletions
  1. +3
    -3
      src/Services/Basket/Basket.API/Basket.API.csproj
  2. +3
    -8
      src/Services/Basket/Basket.API/CustomExtensionMethods.cs
  3. +1
    -17
      src/Services/Basket/Basket.API/GlobalUsings.cs
  4. +2
    -4
      src/Services/Basket/Basket.API/Program.cs
  5. +3
    -0
      src/Services/Basket/Basket.API/appsettings.json
  6. +7
    -3
      src/Services/Basket/Basket.FunctionalTests/appsettings.json

+ 3
- 3
src/Services/Basket/Basket.API/Basket.API.csproj View File

@ -46,9 +46,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
<ProjectReference Include="..\..\BuildingBlocks\EventBus\EventBusServiceBus\EventBusServiceBus.csproj" />
<ProjectReference Include="..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusServiceBus\EventBusServiceBus.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
<ProjectReference Include="..\..\Services.Common\Services.Common.csproj" /> <ProjectReference Include="..\..\Services.Common\Services.Common.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

+ 3
- 8
src/Services/Basket/Basket.API/CustomExtensionMethods.cs View File

@ -2,18 +2,13 @@
public static class CustomExtensionMethods public static class CustomExtensionMethods
{ {
public static IServiceCollection AddRedis(this IServiceCollection services)
public static IServiceCollection AddRedis(this IServiceCollection services, IConfiguration configuration)
{ {
// {
// "ConnectionString": "..."
// }
return services.AddSingleton(sp => return services.AddSingleton(sp =>
{ {
var settings = sp.GetRequiredService<IOptions<BasketSettings>>().Value;
var configuration = ConfigurationOptions.Parse(settings.ConnectionString, true);
var redisConfig = ConfigurationOptions.Parse(configuration.GetConnectionString("redis"), true);
return ConnectionMultiplexer.Connect(configuration);
return ConnectionMultiplexer.Connect(redisConfig);
}); });
} }
} }

+ 1
- 17
src/Services/Basket/Basket.API/GlobalUsings.cs View File

@ -1,7 +1,4 @@
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using Azure.Core;
global using Azure.Identity;
global using Autofac;
global using Basket.API.Infrastructure.ActionResults; global using Basket.API.Infrastructure.ActionResults;
global using Basket.API.Infrastructure.Exceptions; global using Basket.API.Infrastructure.Exceptions;
global using Basket.API.Infrastructure.Filters; global using Basket.API.Infrastructure.Filters;
@ -11,24 +8,15 @@ global using Basket.API.IntegrationEvents.Events;
global using Basket.API.Model; global using Basket.API.Model;
global using Grpc.Core; global using Grpc.Core;
global using GrpcBasket; global using GrpcBasket;
global using HealthChecks.UI.Client;
global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Authorization;
global using Microsoft.AspNetCore.Builder; global using Microsoft.AspNetCore.Builder;
global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
global using Microsoft.AspNetCore.Hosting; global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http.Features;
global using Microsoft.AspNetCore.Http; global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.Mvc.Authorization; global using Microsoft.AspNetCore.Mvc.Authorization;
global using Microsoft.AspNetCore.Mvc.Filters; global using Microsoft.AspNetCore.Mvc.Filters;
global using Microsoft.AspNetCore.Mvc; global using Microsoft.AspNetCore.Mvc;
global using Microsoft.AspNetCore.Server.Kestrel.Core;
global using Microsoft.AspNetCore;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
global using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
global using Microsoft.eShopOnContainers.Services.Basket.API.Controllers;
global using Microsoft.eShopOnContainers.Services.Basket.API.Infrastructure.Repositories; global using Microsoft.eShopOnContainers.Services.Basket.API.Infrastructure.Repositories;
global using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling; global using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling;
global using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events; global using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events;
@ -37,19 +25,15 @@ global using Microsoft.eShopOnContainers.Services.Basket.API.Services;
global using Microsoft.eShopOnContainers.Services.Basket.API; global using Microsoft.eShopOnContainers.Services.Basket.API;
global using Microsoft.Extensions.Configuration; global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection; global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Diagnostics.HealthChecks;
global using Microsoft.Extensions.Hosting; global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using Microsoft.OpenApi.Models; global using Microsoft.OpenApi.Models;
global using RabbitMQ.Client;
global using Serilog.Context; global using Serilog.Context;
global using Serilog; global using Serilog;
global using StackExchange.Redis; global using StackExchange.Redis;
global using Swashbuckle.AspNetCore.SwaggerGen; global using Swashbuckle.AspNetCore.SwaggerGen;
global using System.Collections.Generic; global using System.Collections.Generic;
global using System.ComponentModel.DataAnnotations; global using System.ComponentModel.DataAnnotations;
global using System.IdentityModel.Tokens.Jwt;
global using System.IO; global using System.IO;
global using System.Linq; global using System.Linq;
global using System.Net; global using System.Net;


+ 2
- 4
src/Services/Basket/Basket.API/Program.cs View File

@ -21,9 +21,7 @@ builder.WebHost.UseFailing(options =>
options.NotFilteredPaths.AddRange(new[] { "/hc", "/liveness" }); options.NotFilteredPaths.AddRange(new[] { "/hc", "/liveness" });
}); });
builder.Services.Configure<BasketSettings>(builder.Configuration);
builder.Services.AddRedis();
builder.Services.AddRedis(builder.Configuration);
builder.Services.AddTransient<ProductPriceChangedIntegrationEventHandler>(); builder.Services.AddTransient<ProductPriceChangedIntegrationEventHandler>();
builder.Services.AddTransient<OrderStartedIntegrationEventHandler>(); builder.Services.AddTransient<OrderStartedIntegrationEventHandler>();
@ -33,7 +31,7 @@ builder.Services.AddTransient<IIdentityService, IdentityService>();
var app = builder.Build(); var app = builder.Build();
app.MapGet("hello", () => "hello");
app.MapGet("/", () => Results.Redirect("/swagger"));
app.UseServiceDefaults(); app.UseServiceDefaults();


+ 3
- 0
src/Services/Basket/Basket.API/appsettings.json View File

@ -16,6 +16,9 @@
"Protocols": "Http2" "Protocols": "Http2"
} }
}, },
"ConnectionStrings": {
"Redis": "127.0.0.1"
},
"EventBus": { "EventBus": {
"SubscriptionClientName": "Basket", "SubscriptionClientName": "Basket",
"ConnectionString": "your-event-bus-connection-string", "ConnectionString": "your-event-bus-connection-string",


+ 7
- 3
src/Services/Basket/Basket.FunctionalTests/appsettings.json View File

@ -11,9 +11,13 @@
}, },
"IdentityUrl": "http://localhost:5105", "IdentityUrl": "http://localhost:5105",
"IdentityUrlExternal": "http://localhost:5105", "IdentityUrlExternal": "http://localhost:5105",
"ConnectionString": "127.0.0.1",
"ConnectionStrings": {
"Redis": "127.0.0.1"
},
"EventBus": {
"ConnectionString": "localhost",
"SubscriptionClientName": "Basket"
},
"isTest": "true", "isTest": "true",
"EventBusConnection": "localhost",
"SubscriptionClientName": "Basket",
"SuppressCheckForUnhandledSecurityMetadata": true "SuppressCheckForUnhandledSecurityMetadata": true
} }

Loading…
Cancel
Save