aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-09-11 09:52:31 +0100
committerChristopher Baines <mail@cbaines.net>2023-09-12 13:11:00 +0100
commitaa009075d6757ced963250e849b0cdf5764a2f52 (patch)
treeb836d9df69bbb2d44060c2d6ae990fb933c2e1c7 /scripts
parent318f4072fadf984c287d35258048003f6f26aebd (diff)
downloadnar-herder-aa009075d6757ced963250e849b0cdf5764a2f52.tar
nar-herder-aa009075d6757ced963250e849b0cdf5764a2f52.tar.gz
Use recent changes to trigger nar mirroring and removal
As this should be more efficient than repeatedly looking through all the nars in the database.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/nar-herder.in66
1 files changed, 36 insertions, 30 deletions
diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in
index 0736592..5991d02 100644
--- a/scripts/nar-herder.in
+++ b/scripts/nar-herder.in
@@ -629,37 +629,43 @@
(* 24 3600) ; 24 hours
(assq-ref opts 'recent-changes-limit))
- (and=> (assq-ref opts 'mirror)
- (lambda (mirror)
- (start-fetch-changes-fiber database
+ (let ((mirror-channel
+ (and=>
+ (assq-ref opts 'mirror)
+ (lambda (mirror)
+ (start-fetch-changes-fiber database
+ canonical-storage
+ mirror
+ metrics-registry)
+
+ (when (assq-ref opts 'storage)
+ (start-mirroring-fiber database
+ mirror
+ (assq-ref opts 'storage-limit)
+ canonical-storage
+ metrics-registry)))))
+ (removal-channel
+ (let ((nar-removal-criteria
+ (filter-map
+ (match-lambda
+ ((key . val)
+ (if (eq? key 'storage-nar-removal-criteria)
+ val
+ #f)))
+ opts)))
+ (when (and (assq-ref opts 'storage)
+ (number? (assq-ref opts 'storage-limit))
+ (not (null? nar-removal-criteria)))
+ (start-nar-removal-fiber database
canonical-storage
- mirror
- metrics-registry)
-
- (when (assq-ref opts 'storage)
- (start-mirroring-fiber database
- mirror
- (assq-ref opts 'storage-limit)
- canonical-storage
- metrics-registry))))
-
-
- (let ((nar-removal-criteria
- (filter-map
- (match-lambda
- ((key . val)
- (if (eq? key 'storage-nar-removal-criteria)
- val
- #f)))
- opts)))
- (when (and (assq-ref opts 'storage)
- (number? (assq-ref opts 'storage-limit))
- (not (null? nar-removal-criteria)))
- (start-nar-removal-fiber database
- canonical-storage
- (assq-ref opts 'storage-limit)
- metrics-registry
- nar-removal-criteria)))
+ (assq-ref opts 'storage-limit)
+ metrics-registry
+ nar-removal-criteria)))))
+
+ (start-recent-change-listener-fiber
+ database
+ mirror-channel
+ removal-channel))
(wait finished?))
#:hz 0