Skip to content

Commit aaf15d1

Browse files
authored
Merge branch 'TechEmpower:master' into master
2 parents 8825d8c + 67dd589 commit aaf15d1

File tree

73 files changed

+2218
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2218
-465
lines changed
Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
11
{
2-
"framework": "sisk",
3-
"tests": [{
4-
"default": {
5-
"plaintext_url": "/plaintext",
6-
"json_url": "/json",
7-
"port": 8080,
8-
"approach": "Realistic",
9-
"classification": "Fullstack",
10-
"database": "None",
11-
"framework": "Sisk",
12-
"language": "C#",
13-
"orm": "Raw",
14-
"platform": ".NET",
15-
"webserver": "Sisk",
16-
"os": "Linux",
17-
"database_os": "Linux",
18-
"display_name": "Sisk Framework"
19-
}
20-
}]
21-
}
2+
"framework": "sisk",
3+
"tests": [
4+
{
5+
"default": {
6+
"plaintext_url": "/plaintext",
7+
"json_url": "/json",
8+
"port": 8080,
9+
"approach": "Realistic",
10+
"classification": "Micro",
11+
"database": "None",
12+
"framework": "Sisk",
13+
"language": "C#",
14+
"orm": "Raw",
15+
"platform": ".NET",
16+
"webserver": "HttpListener",
17+
"os": "Linux",
18+
"database_os": "Linux",
19+
"display_name": "Sisk Framework"
20+
}
21+
},
22+
{
23+
"cadente": {
24+
"plaintext_url": "/plaintext",
25+
"json_url": "/json",
26+
"port": 8080,
27+
"approach": "Realistic",
28+
"classification": "Platform",
29+
"database": "None",
30+
"framework": "Sisk",
31+
"language": "C#",
32+
"orm": "Raw",
33+
"platform": ".NET",
34+
"webserver": "Cadente",
35+
"os": "Linux",
36+
"database_os": "Linux",
37+
"display_name": "Sisk Framework (Cadente)"
38+
}
39+
}
40+
]
41+
}

frameworks/CSharp/sisk/config.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,24 @@ name = "sisk"
55
urls.plaintext = "/plaintext"
66
urls.json = "/json"
77
approach = "Realistic"
8-
classification = "Fullstack"
8+
classification = "Micro"
99
database = "None"
1010
database_os = "Linux"
1111
os = "Linux"
1212
orm = "Raw"
1313
platform = ".NET"
14-
webserver = "Sisk"
14+
webserver = "HttpListener"
15+
versus = "None"
16+
17+
[cadente]
18+
urls.plaintext = "/plaintext"
19+
urls.json = "/json"
20+
approach = "Realistic"
21+
classification = "Platform"
22+
database = "None"
23+
database_os = "Linux"
24+
os = "Linux"
25+
orm = "Raw"
26+
platform = ".NET"
27+
webserver = "Cadente"
1528
versus = "None"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
2+
WORKDIR /source
3+
4+
# copy csproj and restore as distinct layers
5+
COPY sisk-cadente/*.csproj .
6+
RUN dotnet restore -r linux-musl-x64
7+
8+
# copy and publish app and libraries
9+
COPY sisk-cadente/ .
10+
RUN dotnet publish -c release -o /app -r linux-musl-x64
11+
12+
# final stage/image
13+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
14+
WORKDIR /app
15+
COPY --from=build /app .
16+
17+
ENTRYPOINT ["dotnet", "./sisk.dll"]
18+
19+
EXPOSE 8080
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Text;
2+
using System.Text.Json;
3+
using Sisk.Cadente;
4+
5+
var host = new HttpHost ( 8080, session => {
6+
var request = session.Request;
7+
8+
if (request.Path == "/plaintext") {
9+
SerializePlainTextResponse ( session.Response );
10+
}
11+
else if (request.Path == "/json") {
12+
SerializeJsonResponse ( session.Response );
13+
}
14+
else {
15+
session.Response.StatusCode = 404;
16+
}
17+
} );
18+
19+
host.Start ();
20+
Thread.Sleep ( Timeout.Infinite );
21+
22+
static void SerializePlainTextResponse ( HttpResponse response ) {
23+
var contentBytes = Encoding.UTF8.GetBytes ( "Hello, world!" );
24+
25+
response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain" ) );
26+
response.ResponseStream = new MemoryStream ( contentBytes );
27+
}
28+
29+
static void SerializeJsonResponse ( HttpResponse response ) {
30+
var contentBytes = JsonSerializer.SerializeToUtf8Bytes ( new {
31+
message = "Hello, world!"
32+
} );
33+
34+
response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json; charset=utf-8" ) );
35+
response.ResponseStream = new MemoryStream ( contentBytes );
36+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<ServerGarbageCollection>true</ServerGarbageCollection>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Sisk.Cadente" Version="0.1.42-alpha1" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
using Sisk.Core.Http;
1+
using System.Net.Http.Json;
2+
using Sisk.Core.Http;
23
using Sisk.Core.Routing;
3-
using System.Net.Http.Json;
44

5-
var app = HttpServer.CreateBuilder(host =>
6-
{
7-
host.UseListeningPort("http://+:8080/");
8-
});
5+
var app = HttpServer.CreateBuilder ( host => {
6+
host.UseListeningPort ( "http://+:8080/" );
7+
} ).Build ();
98

10-
app.Router.SetRoute(RouteMethod.Get, "/plaintext", PlainText);
11-
app.Router.SetRoute(RouteMethod.Get, "/json", Json);
9+
app.Router.SetRoute ( RouteMethod.Get, "/plaintext", PlainText );
10+
app.Router.SetRoute ( RouteMethod.Get, "/json", Json );
1211

13-
app.Start();
12+
app.Start ();
1413

15-
static HttpResponse PlainText(HttpRequest request)
16-
{
17-
return new HttpResponse().WithContent("Hello, world!");
14+
static HttpResponse PlainText ( HttpRequest request ) {
15+
return new HttpResponse ( "Hello, world!" );
1816
}
1917

20-
static HttpResponse Json(HttpRequest request)
21-
{
22-
return new HttpResponse().WithContent(JsonContent.Create(new
23-
{
18+
static HttpResponse Json ( HttpRequest request ) {
19+
return new HttpResponse ( JsonContent.Create ( new {
2420
message = "Hello, world!"
25-
}));
21+
} ) );
2622
}

frameworks/CSharp/sisk/sisk/sisk.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Sisk.HttpServer" Version="0.16.2" />
12+
<PackageReference Include="Sisk.HttpServer" Version="1.4.0-beta3" />
1313
</ItemGroup>
1414

1515
</Project>

frameworks/Java/helidon/nima/pom.xml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>io.helidon.applications</groupId>
2323
<artifactId>helidon-se</artifactId>
24-
<version>4.1.2</version>
24+
<version>4.1.5</version>
2525
<relativePath/>
2626
</parent>
2727

@@ -38,6 +38,7 @@
3838
<rocker.version>1.3.0</rocker.version>
3939
<vertx-pg-client.version>4.5.3</vertx-pg-client.version>
4040
<jsoniter.version>0.9.23</jsoniter.version>
41+
<jte.version>3.1.15</jte.version>
4142
</properties>
4243

4344
<dependencies>
@@ -78,9 +79,9 @@
7879
<version>42.6.1</version>
7980
</dependency>
8081
<dependency>
81-
<groupId>com.fizzed</groupId>
82-
<artifactId>rocker-runtime</artifactId>
83-
<version>${rocker.version}</version>
82+
<groupId>gg.jte</groupId>
83+
<artifactId>jte</artifactId>
84+
<version>${jte.version}</version>
8485
</dependency>
8586
<dependency>
8687
<groupId>io.helidon.common.testing</groupId>
@@ -98,7 +99,6 @@
9899
<scope>test</scope>
99100
</dependency>
100101
</dependencies>
101-
102102
<build>
103103
<plugins>
104104
<plugin>
@@ -125,20 +125,21 @@
125125
</execution>
126126
</executions>
127127
</plugin>
128+
128129
<plugin>
129-
<groupId>com.fizzed</groupId>
130-
<artifactId>rocker-maven-plugin</artifactId>
131-
<version>${rocker.version}</version>
130+
<groupId>gg.jte</groupId>
131+
<artifactId>jte-maven-plugin</artifactId>
132+
<version>${jte.version}</version>
133+
<configuration>
134+
<sourceDirectory>${project.basedir}/src/main/resources/views</sourceDirectory>
135+
<contentType>Html</contentType>
136+
</configuration>
132137
<executions>
133138
<execution>
134-
<id>generate-rocker-templates</id>
135139
<phase>generate-sources</phase>
136140
<goals>
137141
<goal>generate</goal>
138142
</goals>
139-
<configuration>
140-
<templateDirectory>src/main/resources</templateDirectory>
141-
</configuration>
142143
</execution>
143144
</executions>
144145
</plugin>

frameworks/Java/helidon/nima/src/main/java/io/helidon/benchmark/nima/JsonSerializer.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.io.IOException;
44
import java.util.Arrays;
5-
import java.util.Map;
65
import java.util.List;
6+
import java.util.Map;
77

88
import com.jsoniter.output.JsonStream;
99
import com.jsoniter.output.JsonStreamPool;
@@ -15,7 +15,7 @@ private JsonSerializer() {
1515
}
1616

1717
/**
18-
* Serialize an instance into a JSON object and return it as a byte array.
18+
* Serialize an instance into a byte array.
1919
*
2020
* @param obj the instance
2121
* @return the byte array
@@ -28,19 +28,31 @@ public static byte[] serialize(Object obj) {
2828
return Arrays.copyOfRange(stream.buffer().data(), 0, stream.buffer().tail());
2929
} catch (IOException e) {
3030
throw new JsonException(e);
31-
} finally {
32-
JsonStreamPool.returnJsonStream(stream);
3331
}
3432
}
3533

3634
/**
37-
* Serialize a map of strings into a JSON object and return it as a byte array.
35+
* Serialize an instance into a JSON stream.
36+
*
37+
* @param obj the instance
38+
* @param stream the JSON stream
39+
*/
40+
public static void serialize(Object obj, JsonStream stream) {
41+
try {
42+
stream.reset(null);
43+
stream.writeVal(obj.getClass(), obj);
44+
} catch (IOException e) {
45+
throw new JsonException(e);
46+
}
47+
}
48+
49+
/**
50+
* Serialize a map of strings into a JSON stream.
3851
*
3952
* @param map the map
40-
* @return the byte array
53+
* @param stream the JSON stream
4154
*/
42-
public static byte[] serialize(Map<String, String> map) {
43-
JsonStream stream = JsonStreamPool.borrowJsonStream();
55+
public static void serialize(Map<String, String> map, JsonStream stream) {
4456
try {
4557
stream.reset(null);
4658
stream.writeObjectStart();
@@ -53,22 +65,18 @@ public static byte[] serialize(Map<String, String> map) {
5365
}
5466
});
5567
stream.writeObjectEnd();
56-
return Arrays.copyOfRange(stream.buffer().data(), 0, stream.buffer().tail());
5768
} catch (IOException e) {
5869
throw new JsonException(e);
59-
} finally {
60-
JsonStreamPool.returnJsonStream(stream);
6170
}
6271
}
6372

6473
/**
65-
* Serialize a list of objects into a JSON array and return it as a byte array.
74+
* Serialize a list of objects into a JSON stream.
6675
*
6776
* @param objs the list of objects
68-
* @return the byte array
77+
* @param stream the JSON stream
6978
*/
70-
public static byte[] serialize(List<?> objs) {
71-
JsonStream stream = JsonStreamPool.borrowJsonStream();
79+
public static void serialize(List<?> objs, JsonStream stream) {
7280
try {
7381
stream.reset(null);
7482
stream.writeArrayStart();
@@ -82,11 +90,8 @@ public static byte[] serialize(List<?> objs) {
8290

8391
}
8492
stream.writeArrayEnd();
85-
return Arrays.copyOfRange(stream.buffer().data(), 0, stream.buffer().tail());
8693
} catch (IOException e) {
8794
throw new JsonException(e);
88-
} finally {
89-
JsonStreamPool.returnJsonStream(stream);
9095
}
9196
}
9297
}

0 commit comments

Comments
 (0)