Ejemplo n.º 1
0
        public PackagesStatusResult GetPackagesStatus(IEnumerable<PackagingSource> sources) {
            var result = new PackagesStatusResult {
                Entries = new List<UpdatePackageEntry>(),
                Errors = new List<Exception>()
            };

            foreach (var source in sources) {
                var sourceResult = GetPackages(source);
                result.DateTimeUtc = sourceResult.DateTimeUtc;
                result.Entries = result.Entries.Concat(sourceResult.Entries);
                result.Errors = result.Errors.Concat(sourceResult.Errors);
            }

            return result;
        }
Ejemplo n.º 2
0
        private PackagesStatusResult GetPackages(PackagingSource packagingSource) {
            // Refresh every 23 hours or when signal was triggered
            return _cacheManager.Get(packagingSource.FeedUrl, ctx => {
                ctx.Monitor(_clock.When(TimeSpan.FromMinutes(60 * 23)));
                ctx.Monitor(_signals.When("PackageUpdateService"));

                // We cache exception because we are calling on a network feed, and failure may
                // take quite some time.
                var result = new PackagesStatusResult {
                    DateTimeUtc = _clock.UtcNow,
                    Entries = new List<UpdatePackageEntry>(),
                    Errors = new List<Exception>()
                };
                try {
                    result.Entries = GetPackagesWorker(packagingSource);
                }
                catch (Exception e) {
                    result.Errors = new[] { e };
                }
                return result;
            });
        }