aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-01-22 17:03:04 +0000
committerChristopher Baines <mail@cbaines.net>2022-02-02 09:44:51 +0000
commitce1dac19ef1790cc371fb3acb679a6ca871e4142 (patch)
tree2c6c6494973d36fec8023f61a330380e79e32a60 /scripts
parent3fdd97406d41e1d4d09d87d3e3fc31ea11f66937 (diff)
downloadnar-herder-ce1dac19ef1790cc371fb3acb679a6ca871e4142.tar
nar-herder-ce1dac19ef1790cc371fb3acb679a6ca871e4142.tar.gz
Support specifying TTL's for narinfo responses
Using the same approach as guix publish.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/nar-herder.in27
1 files changed, 25 insertions, 2 deletions
diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in
index a969910..1cc5a67 100644
--- a/scripts/nar-herder.in
+++ b/scripts/nar-herder.in
@@ -48,7 +48,7 @@
(fibers)
(fibers conditions)
(fibers web server)
- ((guix ui) #:select (read/eval))
+ ((guix ui) #:select (read/eval string->duration))
(guix progress)
(guix narinfo)
(guix derivations)
@@ -116,6 +116,27 @@
(cons (string->symbol sym) rest)))
result)))
+ (option '("ttl") #t #f
+ (lambda (opt name arg result)
+ (let ((duration (string->duration arg)))
+ (unless duration
+ (simple-format (current-error-port)
+ "~A: invalid duration\n"
+ arg)
+ (exit 1))
+ (alist-cons 'narinfo-ttl (time-second duration)
+ result))))
+ (option '("negative-ttl") #t #f
+ (lambda (opt name arg result)
+ (let ((duration (string->duration arg)))
+ (unless duration
+ (simple-format (current-error-port)
+ "~A: invalid duration\n"
+ arg)
+ (exit 1))
+ (alist-cons 'narinfo-negative-ttl (time-second duration)
+ result))))
+
(option '("recent-changes-limit") #t #f
(lambda (opt name arg result)
(alist-cons 'recent-changes-limit
@@ -318,6 +339,8 @@
"starting server\n")
(run-server
(make-request-handler database
- canonical-storage)
+ canonical-storage
+ #:ttl (assq-ref opts 'narinfo-ttl)
+ #:negative-ttl (assq-ref opts 'narinfo-negative-ttl))
#:host (assq-ref opts 'host)
#:port (assq-ref opts 'port))))))