From 949b46c658c74b1a7ba80f80ced20be3335bef79 Mon Sep 17 00:00:00 2001 From: Bardin08 Date: Sat, 18 May 2024 02:23:43 +0300 Subject: [PATCH] Add missing files --- ValidationService.sln | 16 +++++ ValidationService/Program.cs | 59 +++++++++++++++++++ ValidationService/ValidationService.csproj | 32 ++++++++++ .../bin/Debug/net8.0/appsettings.json | 11 ++++ 4 files changed, 118 insertions(+) create mode 100644 ValidationService.sln create mode 100644 ValidationService/Program.cs create mode 100644 ValidationService/ValidationService.csproj create mode 100644 ValidationService/bin/Debug/net8.0/appsettings.json diff --git a/ValidationService.sln b/ValidationService.sln new file mode 100644 index 0000000..f250b8b --- /dev/null +++ b/ValidationService.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ValidationService", "ValidationService\ValidationService.csproj", "{A54FD0C8-AAA8-41D7-A845-08A9970B2AAB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A54FD0C8-AAA8-41D7-A845-08A9970B2AAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A54FD0C8-AAA8-41D7-A845-08A9970B2AAB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A54FD0C8-AAA8-41D7-A845-08A9970B2AAB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A54FD0C8-AAA8-41D7-A845-08A9970B2AAB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/ValidationService/Program.cs b/ValidationService/Program.cs new file mode 100644 index 0000000..011a92d --- /dev/null +++ b/ValidationService/Program.cs @@ -0,0 +1,59 @@ +using MassTransit; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Serilog.Events; +using Trumpee.MassTransit; +using Trumpee.MassTransit.Configuration; +using ValidationService; + +Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("MassTransit", LogEventLevel.Debug) + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .Enrich.FromLogContext() + .WriteTo.Console() + .CreateLogger(); + +var host = CreateHostBuilder(args).Build(); + +Console.WriteLine("Done!"); +await host.RunAsync(); +return; + +static IHostBuilder CreateHostBuilder(string[] args) +{ + return Host.CreateDefaultBuilder(args) + .ConfigureHostConfiguration(config => + { + config.AddEnvironmentVariables(); + config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false); + }) + .UseSerilog() + .ConfigureServices((host, services) => + { + services.AddScoped(); + services.AddScoped(); + + var rabbitTopologyBuilder = new RabbitMqTransportConfigurator(); + rabbitTopologyBuilder.AddExternalConfigurations(x => + { + x.AddConsumer(); + }); + + rabbitTopologyBuilder.UseExternalConfigurations((ctx, cfg) => + { + cfg.ReceiveEndpoint("validate", e => + { + e.BindQueue = true; + e.PrefetchCount = 16; + + e.UseConcurrencyLimit(4); + e.ConfigureConsumer(ctx); + }); + }); + + services.AddConfiguredMassTransit(host.Configuration, rabbitTopologyBuilder); + }); +} diff --git a/ValidationService/ValidationService.csproj b/ValidationService/ValidationService.csproj new file mode 100644 index 0000000..c06c7a3 --- /dev/null +++ b/ValidationService/ValidationService.csproj @@ -0,0 +1,32 @@ + + + + Exe + net8.0 + enable + enable + Linux + + + + + + + + + + + + + + .dockerignore + + + + + + PreserveNewest + + + + diff --git a/ValidationService/bin/Debug/net8.0/appsettings.json b/ValidationService/bin/Debug/net8.0/appsettings.json new file mode 100644 index 0000000..f2a34fb --- /dev/null +++ b/ValidationService/bin/Debug/net8.0/appsettings.json @@ -0,0 +1,11 @@ +{ + "MassTransit": { + "Transport": { + "Host": "localhost", + "VHost": "/", + "Username": "guest", + "Password": "guest", + "Port": 23501 + } + } +}