Made the package indexing more slow.
This commit is contained in:
parent
f4195e2ccc
commit
1d0df6ccaa
|
@ -26,9 +26,17 @@ public class DPackageSearch {
|
|||
private static void startIndexerThread(IndexGenerator indexGenerator) {
|
||||
Thread.ofVirtual().start(() -> {
|
||||
while (true) {
|
||||
System.out.println("Will re-index packages in 10 seconds");
|
||||
try {
|
||||
Thread.sleep(Duration.ofSeconds(10));
|
||||
} catch (InterruptedException e) {
|
||||
System.err.println("Indexing thread interrupted: " + e.getMessage());
|
||||
break;
|
||||
}
|
||||
System.out.println("Re-indexing packages now.");
|
||||
indexGenerator.run();
|
||||
try {
|
||||
Thread.sleep(Duration.ofMinutes(5));
|
||||
Thread.sleep(Duration.ofMinutes(60));
|
||||
} catch (InterruptedException e) {
|
||||
System.err.println("Indexing thread interrupted: " + e.getMessage());
|
||||
break;
|
||||
|
|
|
@ -25,13 +25,14 @@ public record IndexGenerator(
|
|||
Collection<PackageInfo> packages;
|
||||
try {
|
||||
packages = fetcher.fetch();
|
||||
dur = Duration.between(start, Instant.now());
|
||||
System.out.println("Fetched " + packages.size() + " in " + dur.toMillis() + " ms.");
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to fetch packages: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try (PackageIndexer indexer = indexerSupplier.get()) {
|
||||
dur = Duration.between(start, Instant.now());
|
||||
System.out.println("Fetched " + packages.size() + " in " + dur.toMillis() + " ms.");
|
||||
start = Instant.now();
|
||||
for (var pkg : packages) {
|
||||
indexer.addToIndex(pkg);
|
||||
|
|
Loading…
Reference in New Issue