Compare commits

..

No commits in common. "3085d5e778fb8b45fedd6036e48e9c270f25486e" and "0f1c7581b84e2833be1f33627148f4a3ebe87f56" have entirely different histories.

2 changed files with 16 additions and 20 deletions

View File

@ -4,7 +4,7 @@ var builder = WebApplication.CreateBuilder(args);
var startup = new Startup(builder.Configuration); var startup = new Startup(builder.Configuration);
startup.ConfigureServices(builder.Services); await startup.ConfigureServices(builder.Services);
var app = builder.Build(); var app = builder.Build();
startup.Configure(app, app.Environment); startup.Configure(app, app.Environment);

View File

@ -12,32 +12,28 @@ public class Startup(IConfiguration configuration)
{ {
private IConfiguration Configuration { get; } = configuration; private IConfiguration Configuration { get; } = configuration;
public void ConfigureServices(IServiceCollection services) public async Task ConfigureServices(IServiceCollection services)
{ {
services.AddGrpc(); services.AddGrpc();
services.AddGrpcReflection(); services.AddGrpcReflection();
services.AddControllers(); services.AddControllers();
services.AddLogging(); services.AddLogging();
services.AddDbContext<AppDbContext>(options => var rabbitMqConnection = await new ConnectionFactory
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
services.AddSingleton<IChannel>(x =>
{
var rabbitMqConnection = new ConnectionFactory
{ {
HostName = "rabbitmq" HostName = "rabbitmq"
}.CreateConnectionAsync().Result; }.CreateConnectionAsync();
var channel = rabbitMqConnection.CreateChannelAsync().Result; var channel = await rabbitMqConnection.CreateChannelAsync();
channel.QueueDeclareAsync( await channel.QueueDeclareAsync(
RabbitQueues.AuthQueue, RabbitQueues.AuthQueue,
false, false,
false, false,
false, false,
arguments: null).Wait(); arguments: null);
return channel; services.AddSingleton(channel);
});
services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
services.Configure<HeadHunterConfig>(Configuration.GetSection(HeadHunterConfig.SectionName)); services.Configure<HeadHunterConfig>(Configuration.GetSection(HeadHunterConfig.SectionName));