This repository was archived by the owner on Mar 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathLoadPackageVersionDriver.cs
More file actions
69 lines (58 loc) · 2.47 KB
/
LoadPackageVersionDriver.cs
File metadata and controls
69 lines (58 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace NuGet.Insights.Worker.LoadPackageVersion
{
public class LoadPackageVersionDriver : ICatalogLeafScanBatchDriver
{
private readonly PackageVersionStorageService _storageService;
private readonly LatestLeafStorageService<PackageVersionEntity> _latestLeafStorageService;
private readonly ILogger<LoadPackageVersionDriver> _logger;
public LoadPackageVersionDriver(
PackageVersionStorageService storageService,
LatestLeafStorageService<PackageVersionEntity> latestLeafStorageService,
ILogger<LoadPackageVersionDriver> logger)
{
_storageService = storageService;
_latestLeafStorageService = latestLeafStorageService;
_logger = logger;
}
public async Task InitializeAsync()
{
await _storageService.InitializeAsync();
}
public Task InitializeAsync(CatalogIndexScan indexScan)
{
return Task.CompletedTask;
}
public Task<CatalogIndexScanResult> ProcessIndexAsync(CatalogIndexScan indexScan)
{
return Task.FromResult(indexScan.OnlyLatestLeaves ? CatalogIndexScanResult.ExpandLatestLeaves : CatalogIndexScanResult.ExpandAllLeaves);
}
public Task<CatalogPageScanResult> ProcessPageAsync(CatalogPageScan pageScan)
{
return Task.FromResult(CatalogPageScanResult.ExpandRemoveDuplicates);
}
public async Task<BatchMessageProcessorResult<CatalogLeafScan>> ProcessLeavesAsync(IReadOnlyList<CatalogLeafScan> leafScans)
{
var storage = await _storageService.GetLatestPackageLeafStorageAsync();
await _latestLeafStorageService.AddAsync(leafScans, storage);
return BatchMessageProcessorResult<CatalogLeafScan>.Empty;
}
public Task StartAggregateAsync(CatalogIndexScan indexScan)
{
return Task.CompletedTask;
}
public Task<bool> IsAggregateCompleteAsync(CatalogIndexScan indexScan)
{
return Task.FromResult(true);
}
public Task FinalizeAsync(CatalogIndexScan indexScan)
{
return Task.CompletedTask;
}
public async Task DestroyOutputAsync()
{
await _storageService.DestroyAsync();
}
}
}