Class NoaaEncFeedIndexer
- Namespace
- EncDotNet.S100.Collections.Indexing
- Assembly
- EncDotNet.S100.Collections.dll
Indexes a NoaaEncFeedSource: fetches (or revalidates) the NOAA ENC product catalogue and turns each cell passing the source's NoaaEncFilter into an online item carrying its coverage, edition and download.
public sealed class NoaaEncFeedIndexer : ICollectionSourceIndexer
- Inheritance
-
NoaaEncFeedIndexer
- Implements
- Inherited Members
Remarks
The raw catalogue is cached on disk once per URL and shared by every NOAA source, whatever its filter. See FeedCacheOptions for how often the server is asked for changes. Nothing is downloaded but the catalogue itself.
Items are RemoteItemLocations. Whether a downloaded copy exists locally is decided by the host at runtime, so the index does not change when cells are downloaded.
Constructors
NoaaEncFeedIndexer(HttpClient, string, FeedCacheOptions?, TimeProvider?)
Creates an indexer.
public NoaaEncFeedIndexer(HttpClient httpClient, string cacheDirectory, FeedCacheOptions? options = null, TimeProvider? timeProvider = null)
Parameters
httpClientHttpClientThe client used to fetch catalogues.
cacheDirectorystringWhere raw catalogues are cached.
optionsFeedCacheOptionsCache options; defaults to Default.
timeProviderTimeProviderThe clock; defaults to System.
Methods
CanIndex(CollectionSource)
Returns true when this indexer handles source.
public bool CanIndex(CollectionSource source)
Parameters
sourceCollectionSource
Returns
GetCatalogAsync(Uri, bool, CancellationToken)
Returns the (cached or freshly fetched) catalogue at
catalogUri, for example to present its
NoaaEncFacets when choosing a filter.
public Task<NoaaEncProductCatalog> GetCatalogAsync(Uri catalogUri, bool forceRevalidate = false, CancellationToken cancellationToken = default)
Parameters
catalogUriUriThe catalogue URL.
forceRevalidateboolAsk the server for changes even if the cached copy is recent.
cancellationTokenCancellationTokenCancels the request.
Returns
Exceptions
- HttpRequestException
The server could not be reached and nothing is cached.
GetFingerprintAsync(CollectionSource, CancellationToken)
Cheaply computes a fingerprint of the source's current state. When it equals a previous index's Fingerprint, that index is still valid. Returns null when the state cannot be determined (for example the source is unavailable).
public ValueTask<string?> GetFingerprintAsync(CollectionSource source, CancellationToken cancellationToken)
Parameters
sourceCollectionSourcecancellationTokenCancellationToken
Returns
Remarks
Revalidates the cached catalogue when due (a cheap conditional request). When the server cannot be reached, the cached catalogue's version is returned, so an existing index is kept rather than rebuilt.
IndexAsync(CollectionSource, IProgress<IndexProgress>?, CancellationToken)
Indexes source.
public ValueTask<SourceIndex> IndexAsync(CollectionSource source, IProgress<IndexProgress>? progress, CancellationToken cancellationToken)
Parameters
sourceCollectionSourceprogressIProgress<IndexProgress>cancellationTokenCancellationToken
Returns
Map(NoaaEncCell)
Maps one catalogue cell onto a neutral item.
public static CollectionItem Map(NoaaEncCell cell)
Parameters
cellNoaaEncCell