Skip to content

Commit 72cffb8

Browse files
Fix and update Watson to latest (#10183)
1 parent 6ba61ce commit 72cffb8

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

frameworks/CSharp/watson/Benchmarks/Benchmarks.csproj

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

33
<PropertyGroup>
44

5-
<TargetFramework>net5.0</TargetFramework>
6-
<LangVersion>9.0</LangVersion>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<LangVersion>13.0</LangVersion>
77

88
<AssemblyTitle>EmbedIO Benchmarks</AssemblyTitle>
99
<Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description>
@@ -17,8 +17,8 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="System.Text.Json" Version="5.0.0" />
21-
<PackageReference Include="Watson" Version="4.0.0.3" />
20+
<PackageReference Include="System.Text.Json" Version="9.0.10" />
21+
<PackageReference Include="Watson" Version="6.4.0" />
2222
</ItemGroup>
2323

2424
</Project>

frameworks/CSharp/watson/Benchmarks/Program.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
using System;
2-
using System.Linq;
3-
using System.Net;
42
using System.Text.Json;
53
using System.Threading;
64
using System.Threading.Tasks;
75

86
using WatsonWebserver;
7+
using WatsonWebserver.Core;
98

109
namespace Benchmarks
1110
{
@@ -23,7 +22,7 @@ public class JsonResult
2322

2423
public static class Program
2524
{
26-
private static readonly ManualResetEvent _WaitEvent = new ManualResetEvent(false);
25+
private static readonly ManualResetEvent WaitEvent = new(false);
2726

2827
public static async Task<int> Main(string[] args)
2928
{
@@ -33,21 +32,23 @@ public static async Task<int> Main(string[] args)
3332
var host = "tfb-server";
3433
#endif
3534

36-
using var server = new Server(host, 8080, false, DefaultRoute);
35+
var settings = new WebserverSettings(host, 8080, false);
3736

38-
server.Routes.Static.Add(HttpMethod.GET, "/plaintext", PlaintextRoute);
39-
server.Routes.Static.Add(HttpMethod.GET, "/json", JsonRoute);
37+
using var server = new Webserver(settings, DefaultRoute);
38+
39+
server.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/plaintext", PlaintextRoute);
40+
server.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/json", JsonRoute);
4041

4142
try
4243
{
4344
AppDomain.CurrentDomain.ProcessExit += (_, __) =>
4445
{
45-
_WaitEvent.Set();
46+
WaitEvent.Set();
4647
};
4748

4849
await server.StartAsync();
4950

50-
_WaitEvent.WaitOne();
51+
WaitEvent.WaitOne();
5152

5253
return 0;
5354
}
@@ -59,22 +60,21 @@ public static async Task<int> Main(string[] args)
5960
}
6061
}
6162

62-
static async Task DefaultRoute(HttpContext ctx)
63+
static async Task DefaultRoute(HttpContextBase ctx)
6364
{
6465
ctx.Response.StatusCode = 404;
65-
ctx.Response.StatusDescription = "Not Found";
6666

6767
await ctx.Response.Send("Not found.");
6868
}
6969

70-
static async Task PlaintextRoute(HttpContext ctx)
70+
static async Task PlaintextRoute(HttpContextBase ctx)
7171
{
7272
ctx.Response.Headers.Add("Content-Type", "text/plain; charset=UTF-8");
7373

7474
await ctx.Response.Send("Hello, World!");
7575
}
7676

77-
static async Task JsonRoute(HttpContext ctx)
77+
static async Task JsonRoute(HttpContextBase ctx)
7878
{
7979
var response = new JsonResult() { Message = "Hello, World!" };
8080
var serialized = JsonSerializer.Serialize(response);

frameworks/CSharp/watson/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ See the [project website](https://github.com/jchristn/WatsonWebserver) for more
66

77
**Language**
88

9-
* C# 9.0
9+
* C# 13.0
1010

1111
**Platforms**
1212

13-
* .NET 5
13+
* .NET 9
1414

1515
**Web Servers**
1616

frameworks/CSharp/watson/benchmark_config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"os": "Linux",
1717
"database_os": "Linux",
1818
"display_name": "Watson Webserver",
19-
"notes": "",
20-
"tags": ["broken"]
19+
"notes": ""
2120
}
2221
}]
2322
}

frameworks/CSharp/watson/watson.dockerfile

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

44
# copy csproj and restore as distinct layers
@@ -7,10 +7,10 @@ RUN dotnet restore -r linux-musl-x64
77

88
# copy and publish app and libraries
99
COPY Benchmarks/ .
10-
RUN dotnet publish -c release -o /app -r linux-musl-x64
10+
RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained
1111

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

0 commit comments

Comments
 (0)