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 touchsocket webapi framework #9098

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Add touchsocket webapi framework
RRQM committed Jun 7, 2024
commit e41f9a3883cdfb3dea92295434d47911d1a35151
37 changes: 37 additions & 0 deletions frameworks/CSharp/touchsocket/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[Oo]bj/
[Bb]in/
TestResults/
.nuget/
*.sln.ide/
_ReSharper.*/
.idea/
packages/
artifacts/
PublishProfiles/
.vs/
*.user
*.suo
*.cache
*.docstates
_ReSharper.*
nuget.exe
*net45.csproj
*net451.csproj
*k10.csproj
*.psess
*.vsp
*.pidb
*.userprefs
*DS_Store
*.ncrunchsolution
*.*sdf
*.ipch
*.swp
*~
.build/
.testPublish/
launchSettings.json
BenchmarkDotNet.Artifacts/
BDN.Generated/
binaries/
global.json
31 changes: 31 additions & 0 deletions frameworks/CSharp/touchsocket/Benchmarks.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31717.71
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi_v2_0", "src\WebApi_v2_0\WebApi_v2_0.csproj", "{1EC18CF4-99D7-45C7-9FB2-FD8559071109}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug_Database|Any CPU = Debug_Database|Any CPU
Debug|Any CPU = Debug|Any CPU
Release_Database|Any CPU = Release_Database|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1EC18CF4-99D7-45C7-9FB2-FD8559071109}.Debug_Database|Any CPU.ActiveCfg = Debug|Any CPU
{1EC18CF4-99D7-45C7-9FB2-FD8559071109}.Debug_Database|Any CPU.Build.0 = Debug|Any CPU
{1EC18CF4-99D7-45C7-9FB2-FD8559071109}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EC18CF4-99D7-45C7-9FB2-FD8559071109}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EC18CF4-99D7-45C7-9FB2-FD8559071109}.Release_Database|Any CPU.ActiveCfg = Release|Any CPU
{1EC18CF4-99D7-45C7-9FB2-FD8559071109}.Release_Database|Any CPU.Build.0 = Release|Any CPU
{1EC18CF4-99D7-45C7-9FB2-FD8559071109}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EC18CF4-99D7-45C7-9FB2-FD8559071109}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {69C5D834-F31B-4F07-97EC-E4DD5AF417DE}
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions frameworks/CSharp/touchsocket/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# touchsocket benchmarks

See [touchsocket](https://touchsocket.net/) for more information.

## Infrastructure Software Versions

**Language**

* C# 8.0

53 changes: 53 additions & 0 deletions frameworks/CSharp/touchsocket/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"framework": "touchsocket",
"tests": [
{
"default": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"db_url": "/db",
"query_url": "/queries/",
"fortune_url": "/fortunes",
"update_url": "/updates/",
"cached_query_url": "/cached-worlds/",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "Postgres",
"framework": "touchsocket",
"language": "C#",
"orm": "Raw",
"platform": ".NET",
"flavor": "CoreCLR",
"webserver": "touchsocket",
"os": "Linux",
"database_os": "Linux",
"display_name": "touchsocket",
"notes": ""
},
"minimal": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"db_url": "/db",
"query_url": "/queries/",
"fortune_url": "/fortunes",
"update_url": "/updates/",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
"database": "Postgres",
"framework": "touchsocket webapi",
"language": "C#",
"orm": "Micro",
"platform": ".NET",
"flavor": "CoreCLR",
"webserver": "touchsocket.http",
"os": "Linux",
"database_os": "Linux",
"display_name": "touchsocket webapi",
"notes": "",
"versus": "touchsocket"
}
}
]
}
20 changes: 20 additions & 0 deletions frameworks/CSharp/touchsocket/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[framework]
name = "touchsocket"

[minimal]
urls.plaintext = "/plaintext"
urls.json = "/json"
urls.db = "/db"
urls.query = "/queries/"
urls.fortune = "/fortunes"
urls.update = "/updates/"
urls.cached_query = "/cached-worlds/"
approach = "Realistic"
classification = "Micro"
database = "Postgres"
database_os = "Linux"
os = "Linux"
orm = "Micro"
platform = ".NET"
webserver = "touchsocket"
versus = "touchsocket"
7 changes: 7 additions & 0 deletions frameworks/CSharp/touchsocket/src/WebApi_v2_0/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
64 changes: 64 additions & 0 deletions frameworks/CSharp/touchsocket/src/WebApi_v2_0/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using TouchSocket.Core;
using TouchSocket.Http;
using TouchSocket.Rpc;
using TouchSocket.Sockets;
using TouchSocket.WebApi;
using TouchSocket.WebApi.Swagger;

namespace WebApi_v2_0
{
public class Program
{
public static void Main(string[] args)
{
var builder = Host.CreateApplicationBuilder(args);

builder.Services.AddServiceHostedService<IHttpService, HttpService>(config =>
{
config.SetListenIPHosts(8080)
.ConfigureContainer(a =>
{
a.AddConsoleLogger();
a.AddRpcStore(store =>
{
store.RegisterServer<ApiServer>();
});
})
.ConfigurePlugins(a =>
{
a.UseCheckClear();

a.UseWebApi();

#if DEBUG
a.UseSwagger()
.UseLaunchBrowser();
#endif

a.UseDefaultHttpServicePlugin();
});
});

var host = builder.Build();
host.Run();
}
}

[GeneratorRpcServer]
public partial class ApiServer : RpcServer
{
[Router("/plaintext")]
[WebApi(HttpMethodType.GET)]
public string Plaintext()
{
return "Hello, World!";
}

[Router("/json")]
[WebApi(HttpMethodType.GET)]
public object Json()
{
return new { message = "Hello, World!" };
}
}
}
18 changes: 18 additions & 0 deletions frameworks/CSharp/touchsocket/src/WebApi_v2_0/WebApi_v2_0.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<!--<PublishAot>true</PublishAot>-->
<UserSecretsId>dotnet-WebApi_v2_0-987c185f-10b1-452b-beb6-47d798a5a131</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="TouchSocket.Hosting" Version="2.0.10" />
<PackageReference Include="TouchSocket.WebApi" Version="2.0.10" />
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="2.0.10" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
13 changes: 13 additions & 0 deletions frameworks/CSharp/touchsocket/touchsocket20.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
COPY src/WebApi_v2_0 .
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime

WORKDIR /app
COPY --from=build /app/out ./

EXPOSE 8080

ENTRYPOINT ["dotnet", "WebApi_v2_0.dll"]