Skip to content

Commit e00eca9

Browse files
committed
Rename StreamWriterUpdater to AuxiliaryFileUpdater
Fix up timer order Other renaming polish
1 parent e597004 commit e00eca9

25 files changed

+145
-95
lines changed

src/Logic/Timers/ITimer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface ITimer
1313
/// <summary>
1414
/// Use to group timers that can be run in parallel. Return 0 (<c>default</c>) for simple, parallel execution.
1515
/// </summary>
16-
int Precedence { get; }
16+
int Order { get; }
1717

1818
Task<bool> IsRunningAsync();
1919
Task InitializeAsync();

src/Logic/Timers/TimerExecutionService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public async Task InitializeAsync()
5959
public async Task<IReadOnlyList<TimerState>> GetStateAsync()
6060
{
6161
var pairs = _nameToTimer
62-
.OrderBy(x => x.Value.Precedence)
62+
.OrderBy(x => x.Value.Order)
6363
.ThenBy(x => x.Key, StringComparer.OrdinalIgnoreCase)
6464
.ToList();
6565

@@ -116,7 +116,7 @@ public async Task<bool> ExecuteNowAsync(string timerName)
116116

117117
public async Task ExecuteAsync()
118118
{
119-
await using (var lease = await _leaseService.TryAcquireAsync(nameof(TimerExecutionService)))
119+
await using (var lease = await _leaseService.TryAcquireAsync("TimerExecutionService"))
120120
{
121121
if (!lease.Acquired)
122122
{
@@ -210,9 +210,9 @@ private async Task<bool> ExecuteAsync(ISet<string> timerNames, bool executeNow)
210210
}
211211
}
212212

213-
// Execute timers by precedence.
213+
// Execute timers in ordered groups.
214214
var anyExecuted = false;
215-
foreach (var group in toExecute.GroupBy(x => x.timer.Precedence).OrderBy(x => x.Key))
215+
foreach (var group in toExecute.GroupBy(x => x.timer.Order).OrderBy(x => x.Key))
216216
{
217217
var executed = await Task.WhenAll(group.Select(x => ExecuteAsync(x.timer, x.entity, x.persistAsync, now)));
218218
anyExecuted |= executed.Any(x => x);

src/Worker.Logic/CatalogScan/CatalogScanUpdateTimer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public CatalogScanUpdateTimer(
2525
public TimeSpan Frequency => _options.Value.CatalogScanUpdateFrequency;
2626
public bool AutoStart => _options.Value.AutoStartCatalogScanUpdate;
2727
public bool IsEnabled => true;
28-
public int Precedence => default;
28+
public int Order => 10;
2929

3030
public async Task<bool> ExecuteAsync()
3131
{

src/Worker.Logic/ExplorePackagesWorkerSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public ExplorePackagesWorkerSettings()
1313
AppendResultStorageBucketCount = 1000; // Azure Data Explorer can only import up to 1000 blobs.
1414
AllowBatching = true;
1515
RunAllCatalogScanDriversAsBatch = false;
16-
OnlyKeepLatestInStreamWriterUpdater = true;
16+
OnlyKeepLatestInAuxiliaryFileUpdater = true;
1717
MoveTempToHome = false;
1818
DisabledDrivers = new List<CatalogScanDriverType>();
1919
OldCatalogIndexScansToKeep = 9;
@@ -71,7 +71,7 @@ public ExplorePackagesWorkerSettings()
7171
public int AppendResultStorageBucketCount { get; set; }
7272
public bool AllowBatching { get; set; }
7373
public bool RunAllCatalogScanDriversAsBatch { get; set; }
74-
public bool OnlyKeepLatestInStreamWriterUpdater { get; set; }
74+
public bool OnlyKeepLatestInAuxiliaryFileUpdater { get; set; }
7575
public bool MoveTempToHome { get; set; }
7676
public List<CatalogScanDriverType> DisabledDrivers { get; set; }
7777
public int OldCatalogIndexScansToKeep { get; set; }

src/Worker.Logic/Management/QueueSizeMetricsTimer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public QueueSizeMetricsTimer(
2121
public TimeSpan Frequency => TimeSpan.FromSeconds(30);
2222
public bool AutoStart => true;
2323
public bool IsEnabled => true;
24-
public int Precedence => default;
24+
public int Order => default;
2525

2626
public async Task<bool> ExecuteAsync()
2727
{

src/Worker.Logic/Management/UpdateSecretsTimer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public UpdateSecretsTimer(
3737

3838
public string Name => "UpdateSecrets";
3939
public bool AutoStart => true;
40-
public int Precedence => int.MaxValue;
40+
public int Order => int.MaxValue;
4141

4242
public TimeSpan Frequency
4343
{

src/Worker.Logic/MessageProcessors/StreamWriterUpdater/StreamWriterUpdaterMessage.cs renamed to src/Worker.Logic/MessageProcessors/AuxiliaryFileUpdater/AuxiliaryFileUpdaterMessage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Newtonsoft.Json;
22

3-
namespace Knapcode.ExplorePackages.Worker.StreamWriterUpdater
3+
namespace Knapcode.ExplorePackages.Worker.AuxiliaryFileUpdater
44
{
5-
public class StreamWriterUpdaterMessage<T> : ITaskStateMessage
5+
public class AuxiliaryFileUpdaterMessage<T> : ITaskStateMessage
66
{
77
[JsonProperty("ts")]
88
public TaskStateKey TaskStateKey { get; set; }

src/Worker.Logic/MessageProcessors/StreamWriterUpdater/StreamWriterUpdaterProcessor.cs renamed to src/Worker.Logic/MessageProcessors/AuxiliaryFileUpdater/AuxiliaryFileUpdaterProcessor.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,25 @@
1111
using Microsoft.Extensions.Logging;
1212
using Microsoft.Extensions.Options;
1313

14-
namespace Knapcode.ExplorePackages.Worker.StreamWriterUpdater
14+
namespace Knapcode.ExplorePackages.Worker.AuxiliaryFileUpdater
1515
{
16-
public class StreamWriterUpdaterProcessor<T> : ITaskStateMessageProcessor<StreamWriterUpdaterMessage<T>>
17-
where T : IAsyncDisposable, IAsOfData
16+
public class AuxiliaryFileUpdaterProcessor<T> : ITaskStateMessageProcessor<AuxiliaryFileUpdaterMessage<T>> where T : IAsOfData
1817
{
1918
private const string AsOfTimestampMetadata = "asOfTimestamp";
2019
private const string VersionSetCommitTimestampMetadata = "versionSetCommitTimestamp";
2120

2221
private readonly ServiceClientFactory _serviceClientFactory;
2322
private readonly IVersionSetProvider _versionSetProvider;
24-
private readonly IStreamWriterUpdater<T> _updater;
23+
private readonly IAuxiliaryFileUpdater<T> _updater;
2524
private readonly IOptions<ExplorePackagesWorkerSettings> _options;
26-
private readonly ILogger<StreamWriterUpdaterProcessor<T>> _logger;
25+
private readonly ILogger<AuxiliaryFileUpdaterProcessor<T>> _logger;
2726

28-
public StreamWriterUpdaterProcessor(
27+
public AuxiliaryFileUpdaterProcessor(
2928
ServiceClientFactory serviceClientFactory,
3029
IVersionSetProvider versionSetProvider,
31-
IStreamWriterUpdater<T> updater,
30+
IAuxiliaryFileUpdater<T> updater,
3231
IOptions<ExplorePackagesWorkerSettings> options,
33-
ILogger<StreamWriterUpdaterProcessor<T>> logger)
32+
ILogger<AuxiliaryFileUpdaterProcessor<T>> logger)
3433
{
3534
_serviceClientFactory = serviceClientFactory;
3635
_versionSetProvider = versionSetProvider;
@@ -44,7 +43,7 @@ public static string GetLatestBlobName(string blobName)
4443
return $"latest_{blobName}.csv.gz";
4544
}
4645

47-
public async Task<bool> ProcessAsync(StreamWriterUpdaterMessage<T> message, long dequeueCount)
46+
public async Task<bool> ProcessAsync(AuxiliaryFileUpdaterMessage<T> message, long dequeueCount)
4847
{
4948
await InitializeAsync();
5049

@@ -84,7 +83,7 @@ public async Task<bool> ProcessAsync(StreamWriterUpdaterMessage<T> message, long
8483
}
8584
}
8685

87-
if (_options.Value.OnlyKeepLatestInStreamWriterUpdater)
86+
if (_options.Value.OnlyKeepLatestInAuxiliaryFileUpdater)
8887
{
8988
await WriteDataAsync(versionSet, data, latestBlob);
9089
}

src/Worker.Logic/MessageProcessors/StreamWriterUpdater/StreamWriterUpdaterService.cs renamed to src/Worker.Logic/MessageProcessors/AuxiliaryFileUpdater/AuxiliaryFileUpdaterService.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
using System;
2-
using System.Threading.Tasks;
1+
using System.Threading.Tasks;
32

4-
namespace Knapcode.ExplorePackages.Worker.StreamWriterUpdater
3+
namespace Knapcode.ExplorePackages.Worker.AuxiliaryFileUpdater
54
{
6-
public class StreamWriterUpdaterService<T> : IStreamWriterUpdaterService<T> where T : IAsyncDisposable, IAsOfData
5+
public class AuxiliaryFileUpdaterService<T> : IAuxiliaryFileUpdaterService<T> where T : IAsOfData
76
{
87
private static readonly string StorageSuffix = string.Empty;
98

10-
private readonly IStreamWriterUpdater<T> _updater;
9+
private readonly IAuxiliaryFileUpdater<T> _updater;
1110
private readonly IMessageEnqueuer _messageEnqueuer;
1211
private readonly TaskStateStorageService _taskStateStorageService;
1312
private readonly AutoRenewingStorageLeaseService _leaseService;
1413

15-
public StreamWriterUpdaterService(
16-
IStreamWriterUpdater<T> updater,
14+
public AuxiliaryFileUpdaterService(
15+
IAuxiliaryFileUpdater<T> updater,
1716
IMessageEnqueuer messageEnqueuer,
1817
TaskStateStorageService taskStateStorageService,
1918
AutoRenewingStorageLeaseService leaseService)
@@ -35,7 +34,7 @@ public async Task InitializeAsync()
3534

3635
public async Task<bool> StartAsync()
3736
{
38-
await using (var lease = await _leaseService.TryAcquireAsync($"Start-{_updater.OperationName}"))
37+
await using (var lease = await _leaseService.TryAcquireAsync($"Start-AuxiliaryFileUpdater-{_updater.OperationName}"))
3938
{
4039
if (!lease.Acquired)
4140
{
@@ -46,7 +45,7 @@ public async Task<bool> StartAsync()
4645
StorageSuffix,
4746
_updater.OperationName,
4847
StorageUtility.GenerateDescendingId().ToString());
49-
await _messageEnqueuer.EnqueueAsync(new[] { new StreamWriterUpdaterMessage<T> { TaskStateKey = taskStateKey } });
48+
await _messageEnqueuer.EnqueueAsync(new[] { new AuxiliaryFileUpdaterMessage<T> { TaskStateKey = taskStateKey } });
5049
await _taskStateStorageService.AddAsync(taskStateKey);
5150
return true;
5251
}

src/Worker.Logic/MessageProcessors/StreamWriterUpdater/StreamWriterUpdaterTimer.cs renamed to src/Worker.Logic/MessageProcessors/AuxiliaryFileUpdater/AuxiliaryFileUpdaterTimer.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
using System;
22
using System.Threading.Tasks;
33

4-
namespace Knapcode.ExplorePackages.Worker.StreamWriterUpdater
4+
namespace Knapcode.ExplorePackages.Worker.AuxiliaryFileUpdater
55
{
6-
public class StreamWriterUpdaterTimer<T> : ITimer where T : IAsyncDisposable, IAsOfData
6+
public class AuxiliaryFileUpdaterTimer<T> : ITimer where T : IAsOfData
77
{
8-
private readonly IStreamWriterUpdaterService<T> _service;
9-
private readonly IStreamWriterUpdater<T> _updater;
8+
private readonly IAuxiliaryFileUpdaterService<T> _service;
9+
private readonly IAuxiliaryFileUpdater<T> _updater;
1010

11-
public StreamWriterUpdaterTimer(
12-
IStreamWriterUpdaterService<T> service,
13-
IStreamWriterUpdater<T> updater)
11+
public AuxiliaryFileUpdaterTimer(
12+
IAuxiliaryFileUpdaterService<T> service,
13+
IAuxiliaryFileUpdater<T> updater)
1414
{
1515
_service = service;
1616
_updater = updater;
@@ -20,7 +20,7 @@ public StreamWriterUpdaterTimer(
2020
public TimeSpan Frequency => _updater.Frequency;
2121
public bool IsEnabled => _service.HasRequiredConfiguration;
2222
public bool AutoStart => _updater.AutoStart;
23-
public int Precedence => default;
23+
public int Order => 20;
2424

2525
public async Task<bool> ExecuteAsync()
2626
{

0 commit comments

Comments
 (0)