[AZ-374] Refactor C21: named GoogleMapsTiles HttpClient in DI

- Register IHttpClientFactory named client "GoogleMapsTiles" inside
  AddTileDownloader() with User-Agent and 100s timeout (preserves
  HttpClient's implicit default).
- Resolve the same named client from all three CreateClient() call
  sites in GoogleMapsDownloaderV2 (session token, single-tile,
  batch-tile retry lambda) and drop the duplicated per-call
  UserAgent.ParseAdd setup.
- Expose USER_AGENT, the client name, and the timeout as internal
  consts on GoogleMapsDownloaderV2 so the extension and the
  downloader share one source of truth.
- Add AC test that builds the DI container, resolves the named
  client, and asserts both the User-Agent header and the timeout.
- Archive AZ-374 task file: todo/ -> done/.

175 unit + 5 smoke pass.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-11 04:11:57 +03:00
parent 1ca8c80d7b
commit 89b4bfd245
4 changed files with 36 additions and 6 deletions
@@ -8,6 +8,11 @@ public static class TileDownloaderServiceCollectionExtensions
public static IServiceCollection AddTileDownloader(this IServiceCollection services)
{
services.AddMemoryCache();
services.AddHttpClient(GoogleMapsDownloaderV2.GoogleMapsTilesClientName, c =>
{
c.DefaultRequestHeaders.UserAgent.ParseAdd(GoogleMapsDownloaderV2.UserAgent);
c.Timeout = TimeSpan.FromSeconds(GoogleMapsDownloaderV2.DefaultHttpClientTimeoutSeconds);
});
services.AddSingleton<ISatelliteDownloader, GoogleMapsDownloaderV2>();
services.AddSingleton<ITileService, TileService>();
return services;