using MyTelegram.EventBus.RabbitMQ.Extensions; using MyTelegramConsts = MyTelegram.MyTelegramConsts; Console.Title = "MyTelegram auth server"; Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.Async(c => c.Console(theme: AnsiConsoleTheme.Code)) .WriteTo.Async(c => c.File("Logs/startup-log.txt")) .CreateLogger(); Log.Information( "{Info} {Version}", "MyTelegram Auth Server", typeof(Program).Assembly.GetName().Version ); Log.Information( "{Description} {Url}", "For more information, please visit", MyTelegramConsts.RepositoryUrl ); Log.Information("MyTelegram authentication server starting..."); //Console.ReadLine(); var builder = Host.CreateDefaultBuilder(args); builder.ConfigureAppConfiguration(options => { options.AddEnvironmentVariables(); options.AddCommandLine(args); }); builder.UseSerilog( (context, configuration) => { configuration.ReadFrom.Configuration(context.Configuration); } ); builder.ConfigureServices( (context, services) => { services.Configure( context.Configuration.GetRequiredSection("App") ); services.Configure( context.Configuration.GetRequiredSection("RabbitMQ:EventBus") ); services.Configure( context.Configuration.GetRequiredSection("RabbitMQ:Connections:Default") ); services.AddHostedService(); services.AddAuthServer(); services.AddMyTelegramStackExchangeRedisCache(options => { options.Configuration = context.Configuration.GetValue("Redis:Configuration"); }); services.AddCacheJsonSerializer(options => { options.TypeInfoResolverChain.Add(MyJsonSerializeContext.Default); }); services.AddMyTelegramRabbitMqEventBus(); //services.AddRebusEventBus(options => //{ // var eventBusOptions = context // .Configuration.GetRequiredSection("RabbitMQ:EventBus") // .Get(); // var rabbitMqOptions = context // .Configuration.GetRequiredSection("RabbitMQ:Connections:Default") // .Get(); // options.Transport(t => // { // t.UseRabbitMq( // $"amqp://{rabbitMqOptions!.UserName}:{rabbitMqOptions.Password}@{rabbitMqOptions.HostName}:{rabbitMqOptions.Port}", // eventBusOptions!.ClientName // ) // .ExchangeNames( // eventBusOptions.ExchangeName, // eventBusOptions.TopicExchangeName ?? "RebusTopics" // ); // }); // options.AddSystemTextJson(jsonOptions => // { // jsonOptions.TypeInfoResolverChain.Add(MyJsonSerializeContext.Default); // }); //}); } ); var app = builder.Build(); await app.RunAsync();