Skip to content

Commit 1ceadee

Browse files
committed
fix: fix bug with current implemented healthchecks
1 parent 42af3cf commit 1ceadee

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/CommunityToolkit.Aspire.Hosting.SurrealDb/SurrealDbBuilderExtensions.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Aspire.Hosting.ApplicationModel;
5+
using CommunityToolkit.Aspire.SurrealDb;
56
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.Extensions.Diagnostics.HealthChecks;
68
using SurrealDb.Net;
79
using System.Text;
810
using System.Text.Json;
@@ -186,8 +188,16 @@ public static IResourceBuilder<SurrealDbDatabaseResource> AddDatabase(
186188
string serverName = builder.Resource.Parent.Name;
187189

188190
string healthCheckKey = $"{serverName}_{namespaceName}_{name}_check";
189-
builder.ApplicationBuilder.Services.AddHealthChecks().AddSurreal(_ => surrealDbClient!, healthCheckKey);
190-
191+
// TODO : Bug to be fixed
192+
//builder.ApplicationBuilder.Services.AddHealthChecks().AddSurreal(_ => surrealDbClient!, healthCheckKey);
193+
builder.ApplicationBuilder.Services.AddHealthChecks().Add(new HealthCheckRegistration(
194+
name: healthCheckKey,
195+
_ => new SurrealDbHealthCheck(surrealDbClient!),
196+
failureStatus: null,
197+
tags: null
198+
)
199+
);
200+
191201
return builder.ApplicationBuilder.AddResource(surrealServerDatabase)
192202
.WithHealthCheck(healthCheckKey);
193203
}
@@ -380,7 +390,7 @@ CancellationToken cancellationToken
380390
writer.WriteStartObject("authentication");
381391
writer.WriteString("protocol", "ws");
382392
// How to do host resolution?
383-
writer.WriteString("hostname", $"localhost:{endpoint.Port}");
393+
writer.WriteString("hostname", $"{endpoint.Host}:{endpoint.Port}");
384394
writer.WriteString("mode", "root");
385395
if (uniqueNamespace is not null)
386396
{

0 commit comments

Comments
 (0)