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
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:
@@ -19,7 +19,7 @@ public class WorkerClientService : IWorkerClientService
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public async Task SendToWorkerAsync(SubmitForTesterModel submit, string packagePath)
|
||||
public async Task SendToWorkerAsync(SubmitForTesterModel submit, string packagePath, bool deletePackageAfterSend)
|
||||
{
|
||||
var workerUrl = GetWorkerUrlForLanguage(submit.Language);
|
||||
_logger.LogInformation("Sending submit {SubmitId} to worker at {WorkerUrl}", submit.Id, workerUrl);
|
||||
@@ -56,17 +56,20 @@ public class WorkerClientService : IWorkerClientService
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Clean up downloaded package
|
||||
try
|
||||
if (deletePackageAfterSend)
|
||||
{
|
||||
if (File.Exists(packagePath))
|
||||
// Clean up package file when it is not needed anymore
|
||||
try
|
||||
{
|
||||
File.Delete(packagePath);
|
||||
if (File.Exists(packagePath))
|
||||
{
|
||||
File.Delete(packagePath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete package file {Path}", packagePath);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to delete package file {Path}", packagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user