Compare commits
4 Commits
0f1c7581b8
...
3085d5e778
Author | SHA1 | Date | |
---|---|---|---|
3085d5e778 | |||
8b1ead20c9 | |||
176cf194cd | |||
17cec6dd64 |
@ -4,7 +4,7 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var startup = new Startup(builder.Configuration);
|
||||
|
||||
await startup.ConfigureServices(builder.Services);
|
||||
startup.ConfigureServices(builder.Services);
|
||||
|
||||
var app = builder.Build();
|
||||
startup.Configure(app, app.Environment);
|
||||
|
@ -12,28 +12,32 @@ public class Startup(IConfiguration configuration)
|
||||
{
|
||||
private IConfiguration Configuration { get; } = configuration;
|
||||
|
||||
public async Task ConfigureServices(IServiceCollection services)
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddGrpc();
|
||||
services.AddGrpcReflection();
|
||||
services.AddControllers();
|
||||
services.AddLogging();
|
||||
|
||||
var rabbitMqConnection = await new ConnectionFactory
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
|
||||
|
||||
|
||||
services.AddSingleton<IChannel>(x =>
|
||||
{
|
||||
var rabbitMqConnection = new ConnectionFactory
|
||||
{
|
||||
HostName = "rabbitmq"
|
||||
}.CreateConnectionAsync();
|
||||
var channel = await rabbitMqConnection.CreateChannelAsync();
|
||||
await channel.QueueDeclareAsync(
|
||||
}.CreateConnectionAsync().Result;
|
||||
var channel = rabbitMqConnection.CreateChannelAsync().Result;
|
||||
channel.QueueDeclareAsync(
|
||||
RabbitQueues.AuthQueue,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
arguments: null);
|
||||
services.AddSingleton(channel);
|
||||
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
|
||||
arguments: null).Wait();
|
||||
return channel;
|
||||
});
|
||||
|
||||
services.Configure<HeadHunterConfig>(Configuration.GetSection(HeadHunterConfig.SectionName));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user