feat: kick logs

This commit is contained in:
sam 2024-10-12 23:28:15 +02:00
parent 6cb515c67d
commit f524afb05b
7 changed files with 118 additions and 83 deletions

View file

@ -15,6 +15,15 @@ public class PluralkitApiService(ILogger logger)
private const string ApiBaseUrl = "https://api.pluralkit.me/v2";
private readonly HttpClient _client = new();
private readonly ILogger _logger = logger.ForContext<PluralkitApiService>();
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
}.ConfigureForNodaTime(
new NodaJsonSettings
{
InstantConverter = new NodaPatternConverter<Instant>(InstantPattern.ExtendedIso),
}
);
private readonly ResiliencePipeline _pipeline = new ResiliencePipelineBuilder()
.AddRateLimiter(
@ -59,17 +68,7 @@ public class PluralkitApiService(ILogger logger)
throw new CataloggerError("Non-200 status code from PluralKit API");
}
var jsonOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
}.ConfigureForNodaTime(
new NodaJsonSettings
{
InstantConverter = new NodaPatternConverter<Instant>(InstantPattern.ExtendedIso),
}
);
return await resp.Content.ReadFromJsonAsync<T>(jsonOptions, ct)
return await resp.Content.ReadFromJsonAsync<T>(_jsonOptions, ct)
?? throw new CataloggerError("JSON response from PluralKit API was null");
}