Skip to content

Commit dffc36e

Browse files
committed
Add schedule
1 parent 861f92e commit dffc36e

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

.nais/test/klass-index-job.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ metadata:
77
team: dapla-metadata
88
shared-db: "true"
99
spec:
10+
schedule: "0 30 23 * * *" # Run once per day at 23:30
1011
concurrencyPolicy: Forbid
11-
failedJobsHistoryLimit: 3
1212
restartPolicy: Never
13-
# TODO configure schedule after development is complete
14-
# schedule: "1/10 * * * *"
13+
failedJobsHistoryLimit: 3
1514
successfulJobsHistoryLimit: 3
1615
openSearch:
1716
access: admin

klass-index-job/src/main/java/no/ssb/klass/search/SearchIndexPopulator.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ public static void main(String[] args) {
6262
public void run(String... args) {
6363
log.info("Collecting classifications to index");
6464
CompletableFuture.runAsync(
65-
() -> {
66-
List<Long> ids = classificationRepository.findPublishedClassificationIds();
67-
log.info("Starting to index {} classifications", ids.size());
68-
ids.forEach(indexService::indexAsync);
69-
log.info("Finished indexing all classifications");
70-
}).join();
65+
() -> {
66+
List<Long> ids =
67+
classificationRepository.findPublishedClassificationIds();
68+
log.info("Starting to index {} classifications", ids.size());
69+
ids.forEach(indexService::indexAsync);
70+
log.info("Finished indexing all classifications");
71+
})
72+
.join(); // Block until all complete
7173
}
7274
}

0 commit comments

Comments
 (0)