Skip to content

Commit dd1a9dc

Browse files
jmdjmd
jmd
authored and
jmd
committed
support reset?
1 parent c9706e8 commit dd1a9dc

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/DotJEM.Json.Index2.Management/IJsonIndexManager.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public class JsonIndexManager : IJsonIndexManager
3232
private readonly IJsonDocumentSource jsonDocumentSource;
3333
private readonly IJsonIndexSnapshotManager snapshots;
3434
private readonly IJsonIndexWriter writer;
35-
35+
private readonly IJsonIndex index;
36+
3637
private readonly IInfoStream<JsonIndexManager> infoStream = new InfoStream<JsonIndexManager>();
3738
private readonly DocumentChangesStream changesStream = new();
3839

@@ -44,11 +45,12 @@ public JsonIndexManager(
4445
IJsonDocumentSource jsonDocumentSource,
4546
IJsonIndexSnapshotManager snapshots,
4647
//TODO: Allow multiple indexes and something that can shard
47-
IJsonIndexWriter writer)
48+
IJsonIndex index)
4849
{
4950
this.jsonDocumentSource = jsonDocumentSource;
5051
this.snapshots = snapshots;
51-
this.writer = writer;
52+
this.index = index;
53+
this.writer = new JsonIndexWriter(index);
5254

5355
Tracker = new IngestProgressTracker();
5456
jsonDocumentSource.DocumentChanges.ForEachAsync(CaptureChange);
@@ -105,6 +107,7 @@ public Task UpdateGenerationAsync(string area, long generation)
105107

106108
public async Task ResetIndexAsync()
107109
{
110+
index.Storage.Delete();
108111
await jsonDocumentSource.ResetAsync().ConfigureAwait(false);
109112
}
110113

src/Stress/StressTester/Adapter/IJsonStorageAreaObserver.cs

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public void UpdateGeneration(string area, long value)
6969
public async Task ResetAsync()
7070
{
7171
UpdateGeneration(AreaName, initialGeneration);
72-
7372
}
7473

7574
public void RunUpdateCheck()

src/Stress/StressTester/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
IJsonIndexManager jsonIndexManager = new JsonIndexManager(
7070
new JsonStorageDocumentSource(new JsonStorageAreaObserverFactory(storage, scheduler,areas)),
7171
new JsonIndexSnapshotManager(index, new ZipSnapshotStrategy(".\\app_data\\snapshots"), scheduler, "10s"),
72-
new JsonIndexWriter(index)
72+
index
7373
);
7474

7575
Task run = Task.WhenAll(

0 commit comments

Comments
 (0)