Структура проекта

main
vladzvx 2024-04-03 01:10:04 +03:00
parent 5aed4d3efb
commit 667d632563
25 changed files with 385 additions and 57 deletions

30
development/.dockerignore Normal file
View File

@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**

View File

@ -0,0 +1,42 @@
using Microsoft.AspNetCore.Mvc;
using Sphagnum.Common.Contracts.Messaging;
using Sphagnum.Common.Contracts.Messaging.Messages;
namespace Sphagnum.DebugClient.Controllers
{
[ApiController]
[Route("[controller]/[action]")]
public class TestController : ControllerBase
{
private readonly IMessagingClient _connection;
private static readonly Task? rec;
public TestController(IMessagingClient connection)
{
_connection = connection;
}
[HttpGet]
public string test()
{
return "Ok!";
}
[HttpGet]
public async Task Send(int size)
{
var payload1 = new byte[size];
var payload2 = new byte[size];
for (int i = 0; i < size; i++)
{
payload1[i] = 1;
payload2[i] = 2;
}
var t1 = _connection.Publish(new OutgoingMessage("test", payload1)).AsTask();
var t2 = _connection.Publish(new OutgoingMessage("test", payload2)).AsTask();
await Task.WhenAll(t1, t2);
}
}
}

View File

@ -0,0 +1,27 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Sphagnum.DebugClient/Sphagnum.DebugClient.csproj", "Sphagnum.DebugClient/"]
COPY ["Sphagnum.Client/Sphagnum.Client.csproj", "Sphagnum.Client/"]
COPY ["Sphagnum.Common/Sphagnum.Common.csproj", "Sphagnum.Common/"]
COPY ["Sphagnum.Common.Contracts/Sphagnum.Common.Contracts.csproj", "Sphagnum.Common.Contracts/"]
RUN dotnet restore "./Sphagnum.DebugClient/./Sphagnum.DebugClient.csproj"
COPY . .
WORKDIR "/src/Sphagnum.DebugClient"
RUN dotnet build "./Sphagnum.DebugClient.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Sphagnum.DebugClient.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Sphagnum.DebugClient.dll"]

View File

@ -0,0 +1,26 @@
using Sphagnum.Client;
using Sphagnum.Common.Contracts.Login;
using Sphagnum.Common.Contracts.Messaging;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton(new ConnectionFactory()
{
UserRights = UserRights.All,
Login = "root",
Password = "root",
Hostname = "test_server",
Port = 8081,
});
builder.Services.AddSingleton<IMessagingClient, ClientDefault>();
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Sphagnum.Client\Sphagnum.Client.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Sphagnum.DebugService/Sphagnum.DebugService.csproj", "Sphagnum.DebugService/"]
COPY ["Sphagnum.Server/Sphagnum.Server.csproj", "Sphagnum.Server/"]
COPY ["Sphagnum.Common/Sphagnum.Common.csproj", "Sphagnum.Common/"]
COPY ["Sphagnum.Common.Contracts/Sphagnum.Common.Contracts.csproj", "Sphagnum.Common.Contracts/"]
RUN dotnet restore "./Sphagnum.DebugService/./Sphagnum.DebugService.csproj"
COPY . .
WORKDIR "/src/Sphagnum.DebugService"
RUN dotnet build "./Sphagnum.DebugService.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Sphagnum.DebugService.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Sphagnum.DebugService.dll"]

View File

@ -0,0 +1,12 @@
using Sphagnum.Common.Contracts.Login;
using Sphagnum.Server;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddSingleton<ConnectionFactory>();
builder.Services.AddHostedService<BrokerHost>();
var app = builder.Build();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..\src</DockerfileContext>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Sphagnum.Server\Sphagnum.Server.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,75 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.DebugClient", "Sphagnum.DebugClient\Sphagnum.DebugClient.csproj", "{14411644-F3A0-4E7B-B8E8-215E9A13F9A0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.DebugService", "Sphagnum.DebugService\Sphagnum.DebugService.csproj", "{C4C5FA79-E3D8-40B0-A0A2-907A56C74724}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "debug", "debug", "{4AE1FA70-B8A6-4833-8820-62FD11D837A8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{71CDAFF8-7C3D-4915-8FAA-5C263857AD62}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8E76791F-BA23-44AD-BACB-E14DD5FCE750}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.Client", "..\src\Sphagnum.Client\Sphagnum.Client.csproj", "{F4CA990B-D194-4F50-984E-37E0C06017F2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.Common", "..\src\Sphagnum.Common\Sphagnum.Common.csproj", "{C344FDF3-3D4D-4BC6-B257-4AD907BE1BE4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.Server", "..\src\Sphagnum.Server\Sphagnum.Server.csproj", "{77F76F27-D883-4392-90D5-8F441043F468}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.Common.UnitTests", "..\tests\Sphagnum.Common.UnitTests\Sphagnum.Common.UnitTests.csproj", "{25865911-1F2D-4083-A99C-C65E13F05C14}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{BF7E9B18-1C0F-4AA6-B4BD-F38617B72A1B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{14411644-F3A0-4E7B-B8E8-215E9A13F9A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14411644-F3A0-4E7B-B8E8-215E9A13F9A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14411644-F3A0-4E7B-B8E8-215E9A13F9A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14411644-F3A0-4E7B-B8E8-215E9A13F9A0}.Release|Any CPU.Build.0 = Release|Any CPU
{C4C5FA79-E3D8-40B0-A0A2-907A56C74724}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4C5FA79-E3D8-40B0-A0A2-907A56C74724}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4C5FA79-E3D8-40B0-A0A2-907A56C74724}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4C5FA79-E3D8-40B0-A0A2-907A56C74724}.Release|Any CPU.Build.0 = Release|Any CPU
{F4CA990B-D194-4F50-984E-37E0C06017F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4CA990B-D194-4F50-984E-37E0C06017F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4CA990B-D194-4F50-984E-37E0C06017F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4CA990B-D194-4F50-984E-37E0C06017F2}.Release|Any CPU.Build.0 = Release|Any CPU
{C344FDF3-3D4D-4BC6-B257-4AD907BE1BE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C344FDF3-3D4D-4BC6-B257-4AD907BE1BE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C344FDF3-3D4D-4BC6-B257-4AD907BE1BE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C344FDF3-3D4D-4BC6-B257-4AD907BE1BE4}.Release|Any CPU.Build.0 = Release|Any CPU
{77F76F27-D883-4392-90D5-8F441043F468}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77F76F27-D883-4392-90D5-8F441043F468}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77F76F27-D883-4392-90D5-8F441043F468}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77F76F27-D883-4392-90D5-8F441043F468}.Release|Any CPU.Build.0 = Release|Any CPU
{25865911-1F2D-4083-A99C-C65E13F05C14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25865911-1F2D-4083-A99C-C65E13F05C14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25865911-1F2D-4083-A99C-C65E13F05C14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25865911-1F2D-4083-A99C-C65E13F05C14}.Release|Any CPU.Build.0 = Release|Any CPU
{BF7E9B18-1C0F-4AA6-B4BD-F38617B72A1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF7E9B18-1C0F-4AA6-B4BD-F38617B72A1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF7E9B18-1C0F-4AA6-B4BD-F38617B72A1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF7E9B18-1C0F-4AA6-B4BD-F38617B72A1B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{14411644-F3A0-4E7B-B8E8-215E9A13F9A0} = {4AE1FA70-B8A6-4833-8820-62FD11D837A8}
{C4C5FA79-E3D8-40B0-A0A2-907A56C74724} = {4AE1FA70-B8A6-4833-8820-62FD11D837A8}
{F4CA990B-D194-4F50-984E-37E0C06017F2} = {71CDAFF8-7C3D-4915-8FAA-5C263857AD62}
{C344FDF3-3D4D-4BC6-B257-4AD907BE1BE4} = {71CDAFF8-7C3D-4915-8FAA-5C263857AD62}
{77F76F27-D883-4392-90D5-8F441043F468} = {71CDAFF8-7C3D-4915-8FAA-5C263857AD62}
{25865911-1F2D-4083-A99C-C65E13F05C14} = {8E76791F-BA23-44AD-BACB-E14DD5FCE750}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {42DA8F91-1667-49BC-971D-D83C0870393A}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
namespace SphagnumDevelopmentDebug
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<DockerPublishLocally>False</DockerPublishLocally>
<ProjectGuid>bf7e9b18-1c0f-4aa6-b4bd-f38617b72a1b</ProjectGuid>
<DockerLaunchAction>None</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
<DockerServiceName>sphagnum.debugclient</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>

View File

@ -0,0 +1 @@
version: '3.4'

View File

@ -0,0 +1,22 @@
version: '3.4'
services:
sphagnum.debugclient:
depends_on:
- sphagnum.debugservice
image: sphagnumdebugclient
ports:
- 5000:8080
build:
context: .
dockerfile: Sphagnum.DebugClient/Dockerfile
sphagnum.debugservice:
hostname: test_server
image: sphagnumdebugservice
ports:
- 5001:8080
build:
context: .
dockerfile: Sphagnum.DebugService/Dockerfile

View File

@ -0,0 +1,11 @@
{
"profiles": {
"Docker Compose": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"serviceActions": {
"sphagnum.debugclient": "StartDebugging"
}
}
}
}

View File

@ -30,9 +30,9 @@ namespace Sphagnum.Server.Broker.Services
var processor = new MessagesProcessor(_authInfoStorage, _messagesStorage, _distributor, _dataProcessor);
return processor.ProcessMessage;
});
_connection.Bind(port);
_connection.Listen(1000); //todo разобраться что делает этот параметр.
_acceptationTask = AcceptationWorker(_cts.Token);
_connection?.Bind(port);
_connection?.Listen(1000); //todo разобраться что делает этот параметр.
//_acceptationTask = AcceptationWorker(_cts.Token);
return Task.CompletedTask;
}

View File

@ -1,15 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace Sphagnum.Service.Controllers
{
[ApiController]
[Route("[controller]")]
public class TestController : ControllerBase
{
[HttpGet]
public string Get(string text)
{
return text;
}
}
}

View File

@ -1,14 +0,0 @@
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.MapControllers();
app.Run();

View File

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Sphagnum.Server\Sphagnum.Server.csproj" />
</ItemGroup>
</Project>

View File

@ -9,8 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{834EE1A0-1D4
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.Server", "Sphagnum.Server\Sphagnum.Server.csproj", "{2C86F0B0-B592-4F9E-A1E0-96BC453BCB2B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.Service", "Sphagnum.Service\Sphagnum.Service.csproj", "{88E2533A-8568-440D-B8A9-05A5372129D9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DE8B3036-E476-4A92-92E3-4D0B58FC5137}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sphagnum.Common", "Sphagnum.Common\Sphagnum.Common.csproj", "{D6EACE65-A4A0-40A9-8896-0BB276471C25}"
@ -39,10 +37,6 @@ Global
{2C86F0B0-B592-4F9E-A1E0-96BC453BCB2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C86F0B0-B592-4F9E-A1E0-96BC453BCB2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C86F0B0-B592-4F9E-A1E0-96BC453BCB2B}.Release|Any CPU.Build.0 = Release|Any CPU
{88E2533A-8568-440D-B8A9-05A5372129D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88E2533A-8568-440D-B8A9-05A5372129D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88E2533A-8568-440D-B8A9-05A5372129D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88E2533A-8568-440D-B8A9-05A5372129D9}.Release|Any CPU.Build.0 = Release|Any CPU
{D6EACE65-A4A0-40A9-8896-0BB276471C25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6EACE65-A4A0-40A9-8896-0BB276471C25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6EACE65-A4A0-40A9-8896-0BB276471C25}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -70,7 +64,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{0AFD5F86-EAE3-494E-B2E5-77F54EB31653} = {834EE1A0-1D4D-42BD-9F76-F5941DE404C2}
{2C86F0B0-B592-4F9E-A1E0-96BC453BCB2B} = {834EE1A0-1D4D-42BD-9F76-F5941DE404C2}
{88E2533A-8568-440D-B8A9-05A5372129D9} = {834EE1A0-1D4D-42BD-9F76-F5941DE404C2}
{D6EACE65-A4A0-40A9-8896-0BB276471C25} = {834EE1A0-1D4D-42BD-9F76-F5941DE404C2}
{91045A44-09DF-4104-BB69-580C639F29B3} = {84474E24-8329-4E47-B2A7-C9A968B13716}
{B6B57A78-D62D-429F-B647-A06B268ECE25} = {84474E24-8329-4E47-B2A7-C9A968B13716}