Skip to content

Commit 9f21c56

Browse files
committed
update sisk cadente
1 parent f715357 commit 9f21c56

File tree

8 files changed

+137
-23
lines changed

8 files changed

+137
-23
lines changed

frameworks/CSharp/sisk/benchmark_config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@
3636
"database_os": "Linux",
3737
"display_name": "Sisk Framework (Cadente)"
3838
}
39+
},
40+
{
41+
"cadente-aot": {
42+
"plaintext_url": "/plaintext",
43+
"json_url": "/json",
44+
"port": 8080,
45+
"approach": "Realistic",
46+
"classification": "Platform",
47+
"database": "None",
48+
"framework": "Sisk",
49+
"language": "C#",
50+
"orm": "Raw",
51+
"platform": ".NET",
52+
"webserver": "Cadente",
53+
"os": "Linux",
54+
"database_os": "Linux",
55+
"display_name": "Sisk Framework (Cadente, Aot)"
56+
}
3957
}
4058
]
4159
}

frameworks/CSharp/sisk/config.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,16 @@ orm = "Raw"
2626
platform = ".NET"
2727
webserver = "Cadente"
2828
versus = "None"
29+
30+
[cadente-aot]
31+
urls.plaintext = "/plaintext"
32+
urls.json = "/json"
33+
approach = "Realistic"
34+
classification = "Platform"
35+
database = "None"
36+
database_os = "Linux"
37+
os = "Linux"
38+
orm = "Raw"
39+
platform = ".NET"
40+
webserver = "Cadente"
41+
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:9.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 /p:PublishAot=true /p:OptimizationPreference=Speed /p:GarbageCollectionAdaptationMode=0
11+
12+
# final stage/image
13+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
14+
WORKDIR /app
15+
COPY --from=build /app .
16+
17+
ENTRYPOINT ["./sisk"]
18+
19+
EXPOSE 8080
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System.Net;
2+
using System.Text;
3+
using System.Text.Json;
4+
using Sisk.Cadente;
5+
6+
var host = new HttpHost ( new IPEndPoint ( IPAddress.Any, 8080 ) );
7+
host.ContextCreated += Host_ContextCreated;
8+
9+
host.Start ();
10+
Thread.Sleep ( Timeout.Infinite );
11+
12+
void Host_ContextCreated ( HttpHost sender, HttpHostContext session ) {
13+
var request = session.Request;
14+
15+
if (request.Path == "/plaintext") {
16+
SerializePlainTextResponse ( session.Response );
17+
}
18+
else if (request.Path == "/json") {
19+
SerializeJsonResponse ( session.Response );
20+
}
21+
else {
22+
session.Response.StatusCode = 404;
23+
}
24+
}
25+
26+
static void SerializePlainTextResponse ( HttpHostContext.HttpResponse response ) {
27+
28+
var messageBytes = Encoding.UTF8.GetBytes ( "Hello, world!" );
29+
30+
response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain" ) );
31+
response.ResponseStream = new MemoryStream ( messageBytes );
32+
}
33+
34+
static void SerializeJsonResponse ( HttpHostContext.HttpResponse response ) {
35+
36+
var contentBytes = JsonSerializer.SerializeToUtf8Bytes ( new {
37+
message = "Hello, world!"
38+
} );
39+
40+
response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json" ) );
41+
response.ResponseStream = new MemoryStream ( contentBytes );
42+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<ServerGarbageCollection>true</ServerGarbageCollection>
9+
<PublishAot>true</PublishAot>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Sisk.Cadente" Version="0.1.43-alpha2" />
14+
</ItemGroup>
15+
16+
</Project>

frameworks/CSharp/sisk/sisk-cadente.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
22
WORKDIR /source
33

44
# copy csproj and restore as distinct layers
@@ -10,7 +10,7 @@ COPY sisk-cadente/ .
1010
RUN dotnet publish -c release -o /app -r linux-musl-x64
1111

1212
# final stage/image
13-
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
13+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
1414
WORKDIR /app
1515
COPY --from=build /app .
1616

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
using System.Text;
1+
using System.Net;
2+
using System.Text;
23
using System.Text.Json;
34
using Sisk.Cadente;
45

5-
var host = new HttpHost ( 8080, session => {
6+
var host = new HttpHost ( new IPEndPoint ( IPAddress.Any, 8080 ) );
7+
host.ContextCreated += Host_ContextCreated;
8+
9+
host.Start ();
10+
Thread.Sleep ( Timeout.Infinite );
11+
12+
void Host_ContextCreated ( HttpHost sender, HttpHostContext session ) {
613
var request = session.Request;
714

815
if (request.Path == "/plaintext") {
@@ -14,23 +21,22 @@
1421
else {
1522
session.Response.StatusCode = 404;
1623
}
17-
} );
24+
}
1825

19-
host.Start ();
20-
Thread.Sleep ( Timeout.Infinite );
26+
static void SerializePlainTextResponse ( HttpHostContext.HttpResponse response ) {
2127

22-
static void SerializePlainTextResponse ( HttpResponse response ) {
23-
var contentBytes = Encoding.UTF8.GetBytes ( "Hello, world!" );
28+
var messageBytes = Encoding.UTF8.GetBytes ( "Hello, world!" );
2429

2530
response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain" ) );
26-
response.ResponseStream = new MemoryStream ( contentBytes );
31+
response.ResponseStream = new MemoryStream ( messageBytes );
2732
}
2833

29-
static void SerializeJsonResponse ( HttpResponse response ) {
34+
static void SerializeJsonResponse ( HttpHostContext.HttpResponse response ) {
35+
3036
var contentBytes = JsonSerializer.SerializeToUtf8Bytes ( new {
3137
message = "Hello, world!"
3238
} );
3339

34-
response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json; charset=utf-8" ) );
40+
response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json" ) );
3541
response.ResponseStream = new MemoryStream ( contentBytes );
3642
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

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>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<ServerGarbageCollection>true</ServerGarbageCollection>
9+
</PropertyGroup>
1010

11-
<ItemGroup>
12-
<PackageReference Include="Sisk.Cadente" Version="0.1.42-alpha1" />
13-
</ItemGroup>
11+
<ItemGroup>
12+
<PackageReference Include="Sisk.Cadente" Version="0.1.43-alpha2" />
13+
</ItemGroup>
1414

15-
</Project>
15+
</Project>

0 commit comments

Comments
 (0)