Class SecomRegistry
- Namespace
- EncDotNet.S100.Collections.Secom
- Assembly
- EncDotNet.S100.Collections.dll
Reads SECOM service instances from a Maritime Service Registry (issue
#822) through its anonymous v1 search
(POST …/api/secom/v1/searchService), and probes whether a listed
service can be read.
public sealed class SecomRegistry
- Inheritance
-
SecomRegistry
- Inherited Members
Remarks
Registry data is uneven, so the listing is cleaned: deleted instances,
endpoints that are not absolute http(s) URLs on a real host (localhost,
bare host names, MRNs, reserved example domains) and duplicate endpoints
are dropped; product types are normalised (S124 → S-124); and
geometry registered with longitudes off by whole turns (−414° for −54°) is
shifted back.
The listing is cached on disk and reused for RefreshInterval; when the registry cannot be reached, the cached copy is served with Stale set.
Constructors
SecomRegistry(HttpClient, string?, Uri?, TimeProvider?, SecomServerTrust?)
Creates a registry reader.
public SecomRegistry(HttpClient httpClient, string? cacheDirectory = null, Uri? searchUri = null, TimeProvider? timeProvider = null, SecomServerTrust? serverTrust = null)
Parameters
httpClientHttpClientThe client used for the registry and for probes. To trust MCP-issued server certificates, give it a handler from
serverTrust.cacheDirectorystringWhere the last listing is kept; null for none.
searchUriUriThe registry's SECOM search; defaults to DefaultSearchUri.
timeProviderTimeProviderThe clock; defaults to System.
serverTrustSecomServerTrustThe validator behind
httpClient's handler, if any; probes then report what it decided (ServerTrust).
Properties
DefaultSearchUri
The MCC Maritime Service Registry's SECOM search.
public static Uri DefaultSearchUri { get; }
Property Value
RefreshInterval
How long a fetched listing is reused before the registry is asked again.
public static TimeSpan RefreshInterval { get; }
Property Value
Methods
GetServicesAsync(bool, CancellationToken)
Lists the registry's usable SECOM services, from the cache when it is
recent (unless forceRefresh).
public Task<SecomRegistryListing> GetServicesAsync(bool forceRefresh = false, CancellationToken cancellationToken = default)
Parameters
forceRefreshboolcancellationTokenCancellationToken
Returns
Exceptions
- HttpRequestException
The registry could not be read and nothing is cached.
NormalizeProduct(string?)
The canonical short form of a SECOM product type (S124,
s-124 → S-124), as the listing gives it; null for none.
public static string? NormalizeProduct(string? value)
Parameters
valuestring
Returns
Parse(string, DateTimeOffset)
Reads a registry search response into cleaned services (for tests and the cache).
public static SecomRegistryListing Parse(string body, DateTimeOffset fetchedAt)
Parameters
bodystringfetchedAtDateTimeOffset
Returns
Exceptions
- InvalidDataException
The body is not a registry search response.
ProbeAsync(Uri, string?, CancellationToken)
Finds out whether the service at serviceUri can be
read: Capability, then one GetSummary page, anonymously;
then, only when that is refused for want of a certificate or a signed
request, once more with the identity identity
resolves to (#883). No other identity is ever tried.
public Task<SecomProbeResult> ProbeAsync(Uri serviceUri, string? identity = null, CancellationToken cancellationToken = default)
Parameters
serviceUriUriThe service's endpoint.
identitystringThe Identity setting to probe with:
default(when null),noneor a reference id. It is resolved through the registry's SecomServerTrust.cancellationTokenCancellationTokenCancels the probe.