Class S100FeedIndexer
- Namespace
- EncDotNet.S100.Collections.Indexing
- Assembly
- EncDotNet.S100.Collections.dll
Indexes an S100FeedSource (issue #680): fetches (or
revalidates) the feed — for example one served by s100 feed serve
— and lists its items, with their coverage, as online items that download
into DownloadFolderFor(Uri).
public sealed class S100FeedIndexer : ICollectionSourceIndexer
- Inheritance
-
S100FeedIndexer
- Implements
- Inherited Members
Remarks
Caching follows NoaaEncFeedIndexer, with a shorter default revalidation interval (one minute), because a served feed follows a folder that may change and an unchanged one answers with a cheap 304. Items keep the publisher's layout, so a downloaded item is resolved to its local copy without re-indexing.
Constructors
S100FeedIndexer(HttpClient, string, FeedCacheOptions?, TimeProvider?)
Creates an indexer.
public S100FeedIndexer(HttpClient httpClient, string cacheDirectory, FeedCacheOptions? options = null, TimeProvider? timeProvider = null)
Parameters
httpClientHttpClientThe client used to fetch feeds.
cacheDirectorystringWhere raw feeds are cached.
optionsFeedCacheOptionsCache options; defaults to DefaultCacheOptions.
timeProviderTimeProviderThe clock; defaults to System.
Properties
DefaultCacheOptions
The default revalidation interval for feeds.
public static FeedCacheOptions DefaultCacheOptions { get; }
Property Value
Methods
CanIndex(CollectionSource)
Returns true when this indexer handles source.
public bool CanIndex(CollectionSource source)
Parameters
sourceCollectionSource
Returns
DownloadFolderFor(Uri)
The managed folder, relative to the downloads root, that items of the
feed at feedUri download into: one per feed, e.g.
feeds/192.168.1.20-8100-3f2a9c1b.
public static string DownloadFolderFor(Uri feedUri)
Parameters
feedUriUri
Returns
GetFeedAsync(Uri, bool, CancellationToken)
Returns the (cached or freshly fetched) feed at feedUri, e.g. to choose products.
public Task<S100FeedDocument> GetFeedAsync(Uri feedUri, bool forceRevalidate = false, CancellationToken cancellationToken = default)
Parameters
feedUriUriforceRevalidateboolcancellationTokenCancellationToken
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
HealthOf(Uri)
How the last attempt to reach the feed at feedUri
went (reachable, or failing since when, with a cached copy or not);
null before the first attempt.
public FeedHealth? HealthOf(Uri feedUri)
Parameters
feedUriUri
Returns
IndexAsync(CollectionSource, IProgress<IndexProgress>?, CancellationToken)
Indexes source.
public ValueTask<SourceIndex> IndexAsync(CollectionSource source, IProgress<IndexProgress>? progress, CancellationToken cancellationToken)
Parameters
sourceCollectionSourceprogressIProgress<IndexProgress>cancellationTokenCancellationToken
Returns
Products(S100FeedDocument)
Summarises the products in feed (item counts and sizes), for choosing a filter.
public static IReadOnlyList<CatalogFacetValue> Products(S100FeedDocument feed)
Parameters
feedS100FeedDocument