private async Task <bool> ProcessPackageLagDetails(CatalogLeaf leaf, DateTimeOffset created, DateTimeOffset lastEdited, bool expectListed, bool isDelete) { var packageId = leaf.PackageId; var packageVersion = leaf.PackageVersion; _logger.LogInformation("Computing Lag for {PackageId} {PackageVersion}", packageId, packageVersion); try { var cancellationToken = new CancellationToken(); var lag = await GetLagForPackageState(_searchInstances, packageId, packageVersion, expectListed, isDelete, created, lastEdited, cancellationToken); if (lag.Ticks > 0) { _logger.LogInformation("Logging {LagInSeconds} seconds lag for {PackageId} {PackageVersion}.", lag.TotalSeconds, packageId, packageVersion); } else { _logger.LogInformation("Lag check for {PackageId} {PackageVersion} was abandoned.", packageId, packageVersion); } } catch { return(false); } return(true); }
protected void AddCatalogLeaf(string path, CatalogLeaf leaf) { var jsonSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; AddCatalogLeaf(path, JsonConvert.SerializeObject(leaf, jsonSettings)); }
private void AddCatalogLeafToMockServer(string path, CatalogLeaf leaf) { var jsonSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; _mockServer.SetAction(path, request => { return(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(leaf, jsonSettings)) })); }); }
/// <summary> /// Attempt to compute lag for a particular leaf against all configured search instances. /// </summary> /// <param name="leaf">Catalog leaf to operate on. Used to get package Id and Versionf</param> /// <param name="created">Created timestamp</param> /// <param name="lastEdited">last edited time stamp.</param> /// <param name="expectListed">true if leaf has listed status true</param> /// <param name="isDelete">true if leaf is a delete</param> /// <returns>Returns the average lag for this leaf over all configured search instances if possible. null otherwise.</returns> public async Task <TimeSpan?> ProcessPackageLagDetailsAsync(CatalogLeaf leaf, DateTimeOffset created, DateTimeOffset lastEdited, bool expectListed, bool isDelete) { var packageId = leaf.PackageId; var packageVersion = leaf.PackageVersion; TimeSpan?lag; _logger.LogInformation("Computing Lag for {PackageId} {PackageVersion}", packageId, packageVersion); try { var cancellationToken = new CancellationToken(); lag = await GetLagForPackageStateAsync(_searchInstances, packageId, packageVersion, expectListed, isDelete, created, lastEdited, cancellationToken); } catch { return(null); } return(lag); }
internal static void AddCatalogLeafToMockServer(MockServerHttpClientHandler clientHandler, Uri uri, CatalogLeaf leaf) { string relativeUrl = uri.IsAbsoluteUri ? uri.AbsolutePath : uri.ToString(); clientHandler.SetAction(relativeUrl, request => { return(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(leaf)) })); }); }
/// <summary> /// Determines if the provided catalog leaf is contains package details. /// </summary> /// <param name="leaf">The catalog leaf.</param> /// <returns>True if the catalog leaf contains package details.</returns> public static bool IsPackageDetails(this CatalogLeaf leaf) { return(leaf.Type.FirstOrDefault() == "PackageDetails"); }