-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into bugfix/7-sign-up-page-design
- Loading branch information
Showing
63 changed files
with
1,225 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
backend/LeetWars.Builder/Extensions/ServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using LeetWars.RabbitMQ; | ||
using Microsoft.Extensions.Options; | ||
using RabbitMQ.Client; | ||
|
||
namespace LeetWars.Builder.Extensions | ||
{ | ||
public static class ServiceCollectionExtensions | ||
{ | ||
public static void RegisterProduceMessagesServices(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.Configure<ConsumerSettings>(configuration.GetSection("RabbitMQConsumer")); | ||
|
||
services.AddSingleton(con => new ConnectionFactory() | ||
{ | ||
Uri = new Uri(configuration["Rabbit"]) | ||
} | ||
.CreateConnection()); | ||
|
||
services.AddSingleton(sp => sp.GetRequiredService<IOptions<ConsumerSettings>>().Value); | ||
services.AddSingleton<IConsumerService, ConsumerService>(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
using LeetWars.Builder.Extensions; | ||
using LeetWars.Builder.Services; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.RegisterProduceMessagesServices(builder.Configuration); | ||
builder.Services.AddHostedService<ConsumeMessages>(); | ||
|
||
var app = builder.Build(); | ||
|
||
app.MapGet("/", () => "Hello World!"); | ||
app.MapGet("/", () => "Hello, world!"); | ||
|
||
app.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using LeetWars.RabbitMQ; | ||
using RabbitMQ.Client.Events; | ||
using System.Text; | ||
|
||
namespace LeetWars.Builder.Services | ||
{ | ||
public class ConsumeMessages : BackgroundService | ||
{ | ||
private readonly IConsumerService _consumerService; | ||
|
||
public ConsumeMessages(IConsumerService consumerService) | ||
{ | ||
_consumerService = consumerService; | ||
} | ||
|
||
protected override Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
var handler = new EventHandler<BasicDeliverEventArgs>((model, args) => | ||
{ | ||
var body = args.Body.ToArray(); | ||
var message = Encoding.UTF8.GetString(body).Replace('"', '\0'); | ||
Console.WriteLine(message); | ||
_consumerService.SetAcknowledge(args.DeliveryTag, true); | ||
}); | ||
|
||
_consumerService.Listen(handler); | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
backend/LeetWars.Core/LeetWars.Core.BLL/Interfaces/IMessageSenderService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace LeetWars.Core.BLL.Interfaces | ||
{ | ||
public interface IMessageSenderService | ||
{ | ||
void SendMessageToRabbitMQ(object obj); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
backend/LeetWars.Core/LeetWars.Core.BLL/Services/MessageSenderService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using LeetWars.Core.BLL.Interfaces; | ||
using LeetWars.RabbitMQ; | ||
using RabbitMQ.Client; | ||
|
||
namespace LeetWars.Core.BLL.Services | ||
{ | ||
public class MessageSenderService : IMessageSenderService | ||
{ | ||
private readonly IProducerService _producerService; | ||
|
||
public MessageSenderService(IProducerService producerService) | ||
{ | ||
_producerService = producerService; | ||
} | ||
|
||
public void SendMessageToRabbitMQ(object obj) | ||
{ | ||
_producerService.Send(obj, ExchangeType.Direct); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base | ||
ARG PROJECT_PORT | ||
WORKDIR /app | ||
EXPOSE $PROJECT_PORT | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||
WORKDIR /src | ||
COPY ["LeetWars.Emailer/LeetWars.Emailer.csproj", "LeetWars.Emailer/"] | ||
RUN dotnet restore "LeetWars.Emailer/LeetWars.Emailer.csproj" | ||
COPY ./LeetWars.Emailer ./LeetWars.Emailer | ||
WORKDIR "/src/LeetWars.Emailer" | ||
RUN dotnet build "LeetWars.Emailer.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "LeetWars.Emailer.csproj" -c Release -o /app/publish /p:UseAppHost=false | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENV ASPNETCORE_URLS http://*:5080 | ||
ENTRYPOINT ["dotnet", "LeetWars.Emailer.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UserSecretsId>e0295497-f79f-4c7d-a0b3-0caebcd03f17</UserSecretsId> | ||
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var builder = WebApplication.CreateBuilder(args); | ||
var app = builder.Build(); | ||
|
||
app.MapGet("/", () => "Hello World!"); | ||
|
||
app.Run(); |
Oops, something went wrong.