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

create dotnet core FastHttpApi http server #4178

Merged
merged 36 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
05174a3
no message
beetlex-io Nov 6, 2018
e6f9295
Update README.md
beetlex-io Nov 6, 2018
74f7bda
change with ' invalid reference format: repository name must be lower…
beetlex-io Nov 6, 2018
609f192
add notfound rewrite
beetlex-io Nov 6, 2018
10f9545
update fasthttpapi to 1.0.0.8
beetlex-io Nov 6, 2018
4ca9747
display error log
beetlex-io Nov 6, 2018
37fea83
set listen port to 80
beetlex-io Nov 6, 2018
1c65a10
no message
beetlex-io Nov 6, 2018
f0226a9
no message
beetlex-io Nov 6, 2018
27f6e65
listen 127.0.0.1
beetlex-io Nov 7, 2018
ff84ba8
no message
beetlex-io Nov 7, 2018
a73623c
test
beetlex-io Nov 7, 2018
e6edc0a
no message
beetlex-io Nov 7, 2018
be52432
support ipv6
beetlex-io Nov 7, 2018
92348c2
no message
beetlex-io Nov 7, 2018
957474f
change benchmark_config sebserver name
beetlex-io Nov 7, 2018
04428aa
no message
beetlex-io Nov 7, 2018
2263cd1
remove console read
beetlex-io Nov 7, 2018
6c806a8
dockerfile add
beetlex-io Nov 8, 2018
00f5bd8
using HostBuilder run app.
beetlex-io Nov 8, 2018
807e0f8
FROM microsoft/dotnet:2.1-runtime-nanoserver
beetlex-io Nov 8, 2018
94eeaba
change logtype to Warring
beetlex-io Nov 8, 2018
eb8151c
add PlatformBenchmarks
beetlex-io Nov 8, 2018
e3b4b20
change beetle-base dockerfile
beetlex-io Nov 8, 2018
ffd4691
PlatformBenchmarks set content-type
beetlex-io Nov 8, 2018
ae0ba77
no message
beetlex-io Nov 8, 2018
9b150bf
change defalut test
beetlex-io Nov 8, 2018
84480b5
update default Benchmarks
beetlex-io Nov 9, 2018
1d5d874
Change the framework name to beetlex
beetlex-io Nov 9, 2018
3d386da
Change using IHostedService
beetlex-io Nov 9, 2018
bce6fe3
change to buider run
beetlex-io Nov 9, 2018
c9d5f69
delete Benchmarks.csproj.user file
beetlex-io Nov 11, 2018
ec10afe
remove PlatformBenchmarks test
beetlex-io Nov 11, 2018
8188894
update header DATE
beetlex-io Nov 12, 2018
e96d838
Remove extra space
beetlex-io Nov 12, 2018
e6cb093
change FastHttpApi directory to beetlex
beetlex-io Nov 13, 2018
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ dependency-reduced-pom.xml
.dart_tool/
*.packages
pubspec.lock
frameworks/CSharp/FastHttpApi/Benchmarks/.vs/
frameworks/CSharp/FastHttpApi/Benchmarks/Properties/PublishProfiles/
frameworks/CSharp/FastHttpApi/Benchmarks/obj/
frameworks/CSharp/carter/
frameworks/CSharp/evhttp-sharp/
frameworks/CSharp/FastHttpApi/.vs/
frameworks/CSharp/FastHttpApi/PlatformBenchmarks/obj/
31 changes: 31 additions & 0 deletions frameworks/CSharp/FastHttpApi/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 15
VisualStudioVersion = 15.0.28010.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{12CA0190-5EA2-460F-ABC4-FAD454148EBF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformBenchmarks", "PlatformBenchmarks\PlatformBenchmarks.csproj", "{4C067352-BD7E-45A0-ACFA-612902887C81}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{12CA0190-5EA2-460F-ABC4-FAD454148EBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12CA0190-5EA2-460F-ABC4-FAD454148EBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12CA0190-5EA2-460F-ABC4-FAD454148EBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12CA0190-5EA2-460F-ABC4-FAD454148EBF}.Release|Any CPU.Build.0 = Release|Any CPU
{4C067352-BD7E-45A0-ACFA-612902887C81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C067352-BD7E-45A0-ACFA-612902887C81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C067352-BD7E-45A0-ACFA-612902887C81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C067352-BD7E-45A0-ACFA-612902887C81}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {08385ADD-0FB3-41AC-83DF-35149057455E}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions frameworks/CSharp/FastHttpApi/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BeetleX.FastHttpApi" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.1" />
</ItemGroup>

</Project>
72 changes: 72 additions & 0 deletions frameworks/CSharp/FastHttpApi/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using BeetleX.FastHttpApi;
using Microsoft.Extensions.Hosting;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading;


namespace Benchmarks
{

[BeetleX.FastHttpApi.Controller]
class Program
{
private static string mDate;
public static void Main(string[] args)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove extra space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank

var builder = new HostBuilder()
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<BeetleXHttpServer>();
});
builder.Build().Run();
}

public object plaintext(IHttpContext context)
{
context.Response.Header[HeaderTypeFactory.DATE] = DateTime.Now.ToUniversalTime().ToString("r");
return new TextResult("Hello, World!");
}
public object json(IHttpContext context)
{
context.Response.Header[HeaderTypeFactory.DATE] = DateTime.Now.ToUniversalTime().ToString("r");
return new JsonResult(new JsonMessage { message = "Hello, World!" });
}

public class JsonMessage
{
public string message { get; set; }
}


}

public class BeetleXHttpServer : IHostedService
{
private HttpApiServer mApiServer;

public virtual Task StartAsync(CancellationToken cancellationToken)
{
mApiServer = new HttpApiServer();
mApiServer.Register(typeof(Program).Assembly);
mApiServer.ServerConfig.Port = 8080;
mApiServer.ServerConfig.MaxConnections = 100000;
mApiServer.ServerConfig.UrlIgnoreCase = false;
mApiServer.ServerConfig.LogLevel = BeetleX.EventArgs.LogType.Warring;
mApiServer.ServerConfig.LogToConsole = true;
mApiServer.Open();
Console.WriteLine("BeetleX FastHttpApi server");
Console.WriteLine($"ServerGC:{System.Runtime.GCSettings.IsServerGC}");
Console.Write(mApiServer.BaseServer);
return Task.CompletedTask;
}

public virtual Task StopAsync(CancellationToken cancellationToken)
{
mApiServer.BaseServer.Dispose();
return Task.CompletedTask;
}
}
}
25 changes: 25 additions & 0 deletions frameworks/CSharp/FastHttpApi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# FastHttpApi Tests on Linux and windows
This includes tests for plaintext and json serialization.

## Infrastructure Software Versions

**Language**

* C# 7.0

**Platforms**

* .NET Core (Windows and Linux)

**Web Servers**

* [FastHttpApi](https://github.com/IKende/FastHttpApi)

**Web Stack**

* [FastHttpApi](https://github.com/IKende/FastHttpApi)

## Paths & Source for Tests

* [Plaintext](Benchmarks/Program.cs): "/plaintext"
* [JSON Serialization](Benchmarks/Program.cs): "/json"
7 changes: 7 additions & 0 deletions frameworks/CSharp/FastHttpApi/beetlex.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM microsoft/dotnet:2.1-sdk-stretch AS build
WORKDIR /app
COPY Benchmarks .
RUN dotnet publish -c Release -o out

WORKDIR /app/out
ENTRYPOINT ["dotnet", "Benchmarks.dll"]
26 changes: 26 additions & 0 deletions frameworks/CSharp/FastHttpApi/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"framework": "beetlex",
"tests": [
{
"default": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
"database": "None",
"framework": "beetlex",
"language": "C#",
"orm": "Raw",
"platform": ".NET",
"flavor": "CoreCLR",
"webserver": "BeetleX",
"os": "Linux",
"database_os": "Linux",
"display_name": "beetlex",
"notes": "",
"versus": "beetlex"
}
}
]
}