Browse Source

[c#/beetlex] update v1.6.5, use System.Text.Json (#6330)

* update beetlex 1.4.3

update beetlex 1.4.3

* docker add COMPlus_ReadyToRun variable
update beetlex

* update beetlex, enabled thread queue

* beetlex framework add db and queries cases

* add db code

* change result json data

* update query url

* beetlex framework add fortunes cases

* change Content-Type

* add beetlex core cases

* fix queries cases

* update config

* change try readline

* update benchmark config

* Update README.md

* Update README.md

* change versus property

* beetlex-core update .net core to v3.0

* change beetlex-core project file

* beetlex update raw db class

* beetlex update raw db

* beetlex debug plaintext

* change debug docker file

* update beetlex to 1.4.0

* update

* beetlex update core 3.1

* [c#/beetlex] add updates cases

* [c#/beetlex] change Server: TFB, change custom connection pool, add update docker

* fix errors

* change pool init

* change connection pool maxsize

* fix fortunes errors

* clear DBRaw _connectionString value.

* [c#beetlex] change update dbconnection pool size

* [c#/beetlex] udpate spanjson to v3.0.1, Npgsql v5.0.0

* [c#/beetlex] add caching sample

* set connectionstring multiplexing

* remove connection multiplexing setting

* [c#/beetlex]change NpgsqlParameter to  NpgsqlParameter<T>

* [c#/beetlex] update dbraw

* [c#/beetlex] change connection string

* [c#/beetlex]  add fortunes cases to core-updb

* update beetlex 1.5.6

* update 5.0.0-alpha1

* update docker file

* Enabled IOQueues

* Set IOQueues debug mode

* update

* [c#/beetlex] udpate to v1.6.0.1-beta

* update pg drive

* [c#/beetlex] update to beetlex v1.6.3 and support pipelining

* set options

* [c#/beetlex] Optimized actions

* [c#/beetlex] update plaintext

* Bump ServiceStack in /frameworks/CSharp/servicestack/src/SelfHost

Bumps [ServiceStack](https://github.com/ServiceStack/ServiceStack) from 3.9.59 to 5.9.2.
- [Release notes](https://github.com/ServiceStack/ServiceStack/releases)
- [Commits](https://github.com/ServiceStack/ServiceStack/commits/v5.9.2)

Signed-off-by: dependabot[bot] <[email protected]>

* [c#/beetlex] change plaintext buffer size, optimize fortunes.

* [c#/beetlex] update v1.6.5,use System.Text.Json

* change docker files

* update beetlex 1.6.5.2

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Henry 4 years ago
parent
commit
8c140b6e16

+ 3 - 0
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs

@@ -4,6 +4,7 @@ using BeetleX.Dispatchs;
 using System;
 using System.Collections.Concurrent;
 using System.Text;
+using System.Text.Json;
 
 namespace PlatformBenchmarks
 {
@@ -22,6 +23,8 @@ namespace PlatformBenchmarks
 
         public ConcurrentQueue<RequestData> Requests { get; set; } = new ConcurrentQueue<RequestData>();
 
+        public Utf8JsonWriter Utf8JsonWriter { get; set; }
+
         public ISession Session { get; set; }
 
         public RequestData CurrentRequest { get; set; }

+ 1 - 1
frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj

@@ -8,7 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="BeetleX" Version="1.6.3" />
+    <PackageReference Include="BeetleX" Version="1.6.5.2" />
     <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
     <PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
     <PackageReference Include="Npgsql" Version="5.0.0" />

+ 3 - 3
frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs

@@ -11,14 +11,14 @@ namespace PlatformBenchmarks
     public partial class HttpHandler
     {
 
-        public async Task db(PipeStream stream, HttpToken token, ISession session)
+        public async ValueTask db(PipeStream stream, HttpToken token, ISession session)
         {
             try
             {
                 var data = await token.Db.LoadSingleQueryRow();
-                await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream);
+                System.Text.Json.JsonSerializer.Serialize<World>(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
             }
-            catch(Exception e_)
+            catch (Exception e_)
             {
                 HttpServer.ApiServer.Log(BeetleX.EventArgs.LogType.Error, null, $"db error {e_.Message}@{e_.StackTrace}");
                 stream.Write(e_.Message);

+ 15 - 4
frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs

@@ -4,18 +4,29 @@ using SpanJson;
 using System;
 using System.Collections.Generic;
 using System.Text;
+using System.Text.Json;
 using System.Threading.Tasks;
 
 namespace PlatformBenchmarks
 {
     public partial class HttpHandler
     {
-        public async Task Json(PipeStream stream, HttpToken token, ISession session)
+        private static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions();
+
+        private static Utf8JsonWriter GetUtf8JsonWriter(PipeStream stream, HttpToken token)
         {
-            JsonMessage jsonMessage = default(JsonMessage);
-            jsonMessage.message = "Hello, World!";
-            await JsonSerializer.NonGeneric.Utf8.SerializeAsync(jsonMessage, stream);
+            var buffer = stream.CreateBufferWriter();
+            var writer = token.Utf8JsonWriter ??= new Utf8JsonWriter(buffer, new JsonWriterOptions { SkipValidation = true });
+            writer.Reset(buffer);
+            return writer;
+        }
+
+        public ValueTask Json(PipeStream stream, HttpToken token, ISession session)
+        {
+
+            System.Text.Json.JsonSerializer.Serialize<JsonMessage>(GetUtf8JsonWriter(stream, token), new JsonMessage { message = "Hello, World!" }, SerializerOptions);
             OnCompleted(stream, session, token);
+            return ValueTask.CompletedTask;
         }
     }
 }

+ 2 - 2
frameworks/CSharp/beetlex/PlatformBenchmarks/queries.cs

@@ -10,7 +10,7 @@ namespace PlatformBenchmarks
 {
     public partial class  HttpHandler
     {
-        public async Task queries(string queryString, PipeStream stream, HttpToken token, ISession session)
+        public async ValueTask queries(string queryString, PipeStream stream, HttpToken token, ISession session)
         {
             int count = 1;
             if(!string.IsNullOrEmpty(queryString))
@@ -31,7 +31,7 @@ namespace PlatformBenchmarks
             try
             {
                 var data = await token.Db.LoadMultipleQueriesRows(count);
-                await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream);
+                System.Text.Json.JsonSerializer.Serialize<World[]>(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
             }
             catch (Exception e_)
             {

+ 2 - 2
frameworks/CSharp/beetlex/PlatformBenchmarks/updates.cs

@@ -10,7 +10,7 @@ namespace PlatformBenchmarks
 {
     public partial class HttpHandler
     {
-        public async Task updates(string queryString, PipeStream stream, HttpToken token, ISession session)
+        public async ValueTask updates(string queryString, PipeStream stream, HttpToken token, ISession session)
         {
             int count = 1;
             if (!string.IsNullOrEmpty(queryString))
@@ -31,7 +31,7 @@ namespace PlatformBenchmarks
             try
             {
                 var data = await token.Db.LoadMultipleUpdatesRows(count);
-                await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream);
+                System.Text.Json.JsonSerializer.Serialize<World[]>(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
             }
             catch (Exception e_)
             {

+ 1 - 1
frameworks/CSharp/beetlex/beetlex-core-updb.dockerfile

@@ -1,4 +1,4 @@
-FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
 WORKDIR /app
 COPY PlatformBenchmarks .
 RUN dotnet publish -c Release -o out

+ 1 - 1
frameworks/CSharp/beetlex/beetlex-core.dockerfile

@@ -1,4 +1,4 @@
-FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
 WORKDIR /app
 COPY PlatformBenchmarks .
 RUN dotnet publish -c Release -o out

+ 1 - 1
frameworks/CSharp/beetlex/beetlex-debug.dockerfile

@@ -1,4 +1,4 @@
-FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
 WORKDIR /app
 COPY PlatformBenchmarks .
 RUN dotnet publish -c Release -o out

+ 1 - 1
frameworks/CSharp/beetlex/beetlex.dockerfile

@@ -1,4 +1,4 @@
-FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
 WORKDIR /app
 COPY Benchmarks .
 RUN dotnet publish -c Release -o out