Browse Source

create dotnet core FastHttpApi http server (#4178)

* no message

* Update README.md

* change with ' invalid reference format: repository name must be lowercase'

* add notfound rewrite

* update fasthttpapi to 1.0.0.8

* display error log

* set listen port to 80

* no message

* no message

* listen 127.0.0.1

* no message

* test

* no message

* support ipv6

* no message

*  change benchmark_config sebserver name

* no message

* remove console read

* dockerfile add
FROM microsoft/dotnet:2.1-runtime-nanoserver

* using HostBuilder run app.

* FROM microsoft/dotnet:2.1-runtime-nanoserver

* change logtype to Warring

* add PlatformBenchmarks

* change beetle-base dockerfile

* PlatformBenchmarks set content-type

* no message

* change defalut test

* update default Benchmarks

* Change the framework name to beetlex

* Change using IHostedService

* change to buider run

* delete Benchmarks.csproj.user file

* remove PlatformBenchmarks test

* update header DATE

* Remove extra space

* change FastHttpApi  directory to beetlex
Henry 6 years ago
parent
commit
7442995b8d

+ 11 - 0
.gitignore

@@ -95,3 +95,14 @@ dependency-reduced-pom.xml
 .dart_tool/
 .dart_tool/
 *.packages
 *.packages
 pubspec.lock
 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/
+frameworks/CSharp/beetlex/Benchmarks/Properties/
+frameworks/CSharp/beetlex/Benchmarks/obj/
+frameworks/CSharp/beetlex/Benchmarks/.vs/
+frameworks/CSharp/beetlex/.vs/

+ 25 - 0
frameworks/CSharp/beetlex/Benchmarks.sln

@@ -0,0 +1,25 @@
+
+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
+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
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {08385ADD-0FB3-41AC-83DF-35149057455E}
+	EndGlobalSection
+EndGlobal

+ 14 - 0
frameworks/CSharp/beetlex/Benchmarks/Benchmarks.csproj

@@ -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>

+ 66 - 0
frameworks/CSharp/beetlex/Benchmarks/Program.cs

@@ -0,0 +1,66 @@
+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
+    {
+        public static void Main(string[] args)
+        {
+            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 - 0
frameworks/CSharp/beetlex/README.md

@@ -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 - 0
frameworks/CSharp/beetlex/beetlex.dockerfile

@@ -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 - 0
frameworks/CSharp/beetlex/benchmark_config.json

@@ -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"
+      }
+    }
+  ]
+}