public GitVersionedConfigProvider(IGitApi git, string repository, string path, string branch, TimeSpan ttl, TimeSpan invalidTtl) { _git = git ?? throw new NullReferenceException(nameof(git)); _ttl = ttl; _invalidTtl = invalidTtl; _gitQuery = new GitQuery(repository, path, branch); _current = TimedEntry.Create(VersionConfig.Fail(new InvalidOperationException()), TimeSpan.Zero); }
private TimedEntry <VersionedConfig> ReadData() { VersionedConfig vc; try { //as all infrastructure is sync var gitItem = _git.GetFile(_gitQuery).ConfigureAwait(false).GetAwaiter().GetResult(); vc = new VersionedConfig(gitItem); } catch (Exception ex) { return(TimedEntry.Create(VersionConfig.Fail(ex), _invalidTtl)); } return(TimedEntry.Create(vc, _ttl)); }