metalTools.ServiceDiscovery
26.10.11.1
dotnet add package metalTools.ServiceDiscovery --version 26.10.11.1
NuGet\Install-Package metalTools.ServiceDiscovery -Version 26.10.11.1
<PackageReference Include="metalTools.ServiceDiscovery" Version="26.10.11.1" />
<PackageVersion Include="metalTools.ServiceDiscovery" Version="26.10.11.1" />
<PackageReference Include="metalTools.ServiceDiscovery" />
paket add metalTools.ServiceDiscovery --version 26.10.11.1
#r "nuget: metalTools.ServiceDiscovery, 26.10.11.1"
#:package metalTools.ServiceDiscovery@26.10.11.1
#addin nuget:?package=metalTools.ServiceDiscovery&version=26.10.11.1
#tool nuget:?package=metalTools.ServiceDiscovery&version=26.10.11.1
metalTools.ServiceDiscovery
A .NET 10 client and fluent JSON registration table for the metalBlender discovery service. Runs on Windows and Linux. The separate DiscoveryHost application listens on TCP port 51220 by default.
Register a server
Bind the application server first, then advertise its actual reachable address and selected port. Configure the discovery machine once in application settings.
using metalTools.ServiceDiscovery;
using var discovery = DiscoveryService.At("discovery-pc");
await using var registration = await discovery.KeepAliveAsync(
DiscoveryService.Server()
.OfType("LiveUi")
.Named("House boiler")
.OnMachine(Environment.MachineName)
.At("192.168.1.20", 51207)
.UsingProtocol("tcp"));
// Run the application server while registration remains in scope.
// Inspect registration.LastError for heartbeat failures.
KeepAliveAsync registers immediately and renews every 15 seconds by default.
Disposing the lease stops renewal and attempts immediate removal. Dispose leases
before their client. If the application crashes, the host expires its entry
after 60 seconds without renewal. Renewals resend the complete registration,
so an active server reappears after a registry restart. A failed heartbeat is
retried at the next interval; the initial registration must succeed.
For caller-controlled heartbeats, use RegisterAsync(service) repeatedly with
the same RegistrationId. Use IdentifiedBy(guid) to retain identity across
process restarts, or keep the generated identity for the process lifetime.
The host generates the UTC alive timestamp; caller timestamps are ignored.
Find servers
using var discovery = DiscoveryService.At("discovery-pc");
var servers = await discovery.FindAsync("LiveUi");
var boiler = servers.FirstOrDefault(server => server.ServiceName == "House boiler");
// Connect with the application's transport using boiler's address and port.
Clients require the discovery machine's address and its known port (default 51220). They do not need to configure a local listening port. The OS assigns outgoing source ports. Queries return snapshots: poll again to update the list. A lease indicates recent registration, not an independent endpoint health check.
Fluent table API
var table = RegistrationTable.Open("services.json")
.WithLifetime(TimeSpan.FromSeconds(60))
.Register(service)
.RemoveExpired();
var matches = table.Find("LiveUi");
table.Remove(service.RegistrationId);
Table updates are synchronized and written through a temporary file before replacement. Use one host process per table file. Malformed files fail startup rather than silently discarding registrations. Expired entries are excluded from queries immediately and removed from disk by periodic host cleanup.
The JSON fields are machine-name, ip-address, protocol, service-type,
service-name, port-number, alive-utc-timestamp, plus registration-id
to distinguish registrations without composite keys.
See the repository's discovery guide for hosting, configuration and integration details.
For local startup, call await discovery.EnsureRunningAsync() before registering
or querying. Install the complete DiscoveryHost publish output beside your app,
or pass DiscoveryLaunchOptions.HostPath. Existing hosts are reused; new hosts
remain running after the client closes. See the discovery guide for deployment,
loopback restrictions, timeouts, and custom table paths.
Automatic local startup
Queries and registrations can reuse or start the independent local DiscoveryHost with WithAutomaticStartup(). Host-managed registration enables this by default. Add metalTools.DiscoveryHost to the executable application to deploy the host into its discovery folder. Remote registries are never replaced locally. See automatic discovery for settings, recovery, deployment, and service ownership.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on metalTools.ServiceDiscovery:
| Package | Downloads |
|---|---|
|
metalTools
Convenience package for LoggerLite, PortDiscovery, StateMachine and ServiceDiscovery. |
|
|
metalTools.ServiceDiscovery.Hosting
Optional .NET Generic Host integration for metalTools.ServiceDiscovery. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.10.11.1 | 193 | 10/11/2026 |
| 26.10.10.1232 | 145 | 10/10/2026 |