Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing files #10

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ValidationService.sln
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions ValidationService/Program.cs
Original file line number Diff line number Diff line change
@@ -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<OffensiveContentValidator>();
services.AddScoped<OffenciveContentValidationService>();

var rabbitTopologyBuilder = new RabbitMqTransportConfigurator();
rabbitTopologyBuilder.AddExternalConfigurations(x =>
{
x.AddConsumer<ValidationConsumer>();
});

rabbitTopologyBuilder.UseExternalConfigurations((ctx, cfg) =>
{
cfg.ReceiveEndpoint("validate", e =>
{
e.BindQueue = true;
e.PrefetchCount = 16;

e.UseConcurrencyLimit(4);
e.ConfigureConsumer<ValidationConsumer>(ctx);
});
});

services.AddConfiguredMassTransit(host.Configuration, rabbitTopologyBuilder);
});
}
32 changes: 32 additions & 0 deletions ValidationService/ValidationService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MassTransit.RabbitMQ" Version="8.1.2" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="trumpee.masstransit" Version="1.0.0.10" />
<PackageReference Include="trumpee.masstransit.messages" Version="1.0.0.8" />
</ItemGroup>

<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions ValidationService/bin/Debug/net8.0/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"MassTransit": {
"Transport": {
"Host": "localhost",
"VHost": "/",
"Username": "guest",
"Password": "guest",
"Port": 23501
}
}
}
Loading