Advanced Query Setup
Customizing Polly
It was mentioned in Getting Started that wait-and-retry Polly policy is configured by default. This waits a certain amount of time after a failed query and then re-attempts it. The number of times the query is retried can be configured when registering the Census REST services:
services.AddCensusRestServices(maxRetryAttempts: 5);
Using Alternative Census Implementations
With Census being, at one point in its history, two years out of date on any static data, the API developer community began to extract and share information through alternative means. Some of these efforts have included Census-like API implementations. We'll be using Sanctuary.Census as one such example.
DbgCensus
can be easily configured to use alternative Census implementations, provided their interface is similar. The REST Sample demonstrates the following instruction by means of configuring a named options instance, so that the configured third-party Census options can be injected anywhere.
Create a
CensusQueryOptions
instance, and point it towards the alternative Census implementation:csharpCensusQueryOptions sanctuaryQueryOptions = new() { RootEndpoint = "https://census.lithafalcon.cc" }
Then, simply pass in these options when creating a query builder.
csharpQueryBuilder builder = new(sanctuaryQueryOptions); // OR IQueryBuilder builder = _queryService.CreateQuery(sanctuaryQueryOptions);