Table of Contents

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

httpClient HttpClient

The client used to fetch catalogues.

cacheDirectory string

Where raw catalogues are cached.

options FeedCacheOptions

Cache options; defaults to Default.

timeProvider TimeProvider

The clock; defaults to System.

Methods

CanIndex(CollectionSource)

Returns true when this indexer handles source.

public bool CanIndex(CollectionSource source)

Parameters

source CollectionSource

Returns

bool

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

catalogUri Uri

The catalogue URL.

forceRevalidate bool

Ask the server for changes even if the cached copy is recent.

cancellationToken CancellationToken

Cancels the request.

Returns

Task<NoaaEncProductCatalog>

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

source CollectionSource
cancellationToken CancellationToken

Returns

ValueTask<string>

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

source CollectionSource
progress IProgress<IndexProgress>
cancellationToken CancellationToken

Returns

ValueTask<SourceIndex>

Map(NoaaEncCell)

Maps one catalogue cell onto a neutral item.

public static CollectionItem Map(NoaaEncCell cell)

Parameters

cell NoaaEncCell

Returns

CollectionItem