Table of Contents

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

httpClient HttpClient

The client used to fetch feeds.

cacheDirectory string

Where raw feeds are cached.

options FeedCacheOptions

Cache options; defaults to DefaultCacheOptions.

timeProvider TimeProvider

The clock; defaults to System.

Properties

DefaultCacheOptions

The default revalidation interval for feeds.

public static FeedCacheOptions DefaultCacheOptions { get; }

Property Value

FeedCacheOptions

Methods

CanIndex(CollectionSource)

Returns true when this indexer handles source.

public bool CanIndex(CollectionSource source)

Parameters

source CollectionSource

Returns

bool

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

feedUri Uri

Returns

string

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

feedUri Uri
forceRevalidate bool
cancellationToken CancellationToken

Returns

Task<S100FeedDocument>

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>

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

feedUri Uri

Returns

FeedHealth

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>

Products(S100FeedDocument)

Summarises the products in feed (item counts and sizes), for choosing a filter.

public static IReadOnlyList<CatalogFacetValue> Products(S100FeedDocument feed)

Parameters

feed S100FeedDocument

Returns

IReadOnlyList<CatalogFacetValue>