Class S100ForecastFeedIndexer
- Namespace
- EncDotNet.S100.Collections.Indexing
- Assembly
- EncDotNet.S100.Collections.dll
Indexes an S100ForecastFeedSource (#685) — for example NOAA's S-111 surface currents on AWS — by reading each chosen model's catalogue, which lists only its latest run.
public sealed class S100ForecastFeedIndexer : ICollectionSourceIndexer
- Inheritance
-
S100ForecastFeedIndexer
- Implements
- Inherited Members
Remarks
Each run is stamped on its items: RunProperty, ValidToProperty (run time plus the model's horizon) and, as LastModified, the run time — runs have no editions, so a downloaded run is outdated once the catalogue lists a later one (IsOlderThan(CollectionItem)). Items keep their identity across runs (the run time is dropped from their names), so a new run's download replaces the previous one.
Catalogues are cached like S100CatalogueFeedIndexer's; a model whose catalogue cannot be read is reported and skipped. When the feed is in an S3 bucket, each run's folder is listed for sizes.
Constructors
S100ForecastFeedIndexer(HttpClient, string, FeedCacheOptions?, TimeProvider?)
Creates an indexer.
public S100ForecastFeedIndexer(HttpClient httpClient, string cacheDirectory, FeedCacheOptions? options = null, TimeProvider? timeProvider = null)
Parameters
httpClientHttpClientThe client used to fetch catalogues and list buckets.
cacheDirectorystringWhere raw catalogues are cached.
optionsFeedCacheOptionsCache options; defaults to DefaultCacheOptions.
timeProviderTimeProviderThe clock; defaults to System.
Fields
ModelProperty
The item property naming its model (e.g. cbofs).
public const string ModelProperty = "model"
Field Value
RunProperty
The item property holding its run time (ISO 8601, UTC).
public const string RunProperty = "run"
Field Value
ValidToProperty
The item property holding the end of its run's valid window (ISO 8601, UTC).
public const string ValidToProperty = "validTo"
Field Value
Properties
DefaultCacheOptions
The default revalidation interval: one minute. A model's catalogue is overwritten with every run, so a Refresh ("Check for new runs") must actually ask; an unchanged catalogue answers with a cheap 304. Hosts refresh only on start and on request, never in the background.
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
CatalogUri(Uri, ForecastModel)
The catalogue of model under modelsUri.
public static Uri CatalogUri(Uri modelsUri, ForecastModel model)
Parameters
modelsUriUrimodelForecastModel
Returns
DownloadFolderFor(Uri)
The managed folder, relative to the downloads root, that a feed's runs
download into: one per feed, e.g. forecasts/noaa-s111-pds.s3.amazonaws.com-3f2a9c1b.
public static string DownloadFolderFor(Uri modelsUri)
Parameters
modelsUriUri
Returns
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
GetModelsAsync(Uri, IReadOnlyList<ForecastModel>, CancellationToken)
Summarises the latest run of each of models under
modelsUri (run time, tiles, sizes and domain), for
choosing models; a model that cannot be read carries its error.
public Task<IReadOnlyList<ForecastModelSummary>> GetModelsAsync(Uri modelsUri, IReadOnlyList<ForecastModel> models, CancellationToken cancellationToken = default)
Parameters
modelsUriUrimodelsIReadOnlyList<ForecastModel>cancellationTokenCancellationToken
Returns
HealthOf(S100ForecastFeedSource)
How the last attempt to reach feed's catalogues
went: the first failing model's, else the most recent check;
null before the first attempt.
public FeedHealth? HealthOf(S100ForecastFeedSource feed)
Parameters
Returns
IndexAsync(CollectionSource, IProgress<IndexProgress>?, CancellationToken)
Indexes source.
public ValueTask<SourceIndex> IndexAsync(CollectionSource source, IProgress<IndexProgress>? progress, CancellationToken cancellationToken)
Parameters
sourceCollectionSourceprogressIProgress<IndexProgress>cancellationTokenCancellationToken
Returns
RunOf(CollectionItem)
The run time of a forecast item, from RunProperty.
public static DateTimeOffset? RunOf(CollectionItem item)
Parameters
itemCollectionItem
Returns
ValidToOf(CollectionItem)
The end of a forecast item's valid window, from ValidToProperty.
public static DateTimeOffset? ValidToOf(CollectionItem item)
Parameters
itemCollectionItem