Improves package download and caching
All checks were successful
Build and Push Docker Images / build (src/LiquidCode.Tester.Gateway/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-gateway-roman, gateway) (push) Successful in 53s
Build and Push Docker Images / build (src/LiquidCode.Tester.Worker/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-worker-roman, worker) (push) Successful in 50s

Adds package caching to reduce download frequency.

Introduces a `PackageDownloadService` with memory caching to store downloaded packages,
identified by mission ID, for reuse. Uses concurrent locks to prevent race conditions during download.

Modifies the worker client service to optionally delete the package after sending,
allowing cached packages to be retained.
This commit is contained in:
2025-11-02 20:05:50 +03:00
parent b95d94d796
commit bf7bd0ad6b
6 changed files with 130 additions and 26 deletions

View File

@@ -3,9 +3,10 @@ namespace LiquidCode.Tester.Gateway.Services;
public interface IPackageDownloadService
{
/// <summary>
/// Downloads a package from the specified URL
/// Retrieves a cached package for the mission or downloads it if missing.
/// </summary>
/// <param name="packageUrl">URL to download the package from</param>
/// <returns>Path to the downloaded package file</returns>
Task<string> DownloadPackageAsync(string packageUrl);
/// <param name="missionId">Unique mission identifier used as cache key.</param>
/// <param name="packageUrl">URL to download the package from when cache is cold.</param>
/// <returns>Path to the cached or downloaded package file.</returns>
Task<string> GetOrDownloadPackageAsync(long missionId, string packageUrl);
}